I\'m an ubuntu 16.4 user and I installed anaconda3 and using both python2 and python3 kernels.
>>>jupyter kernelspec list Available kernels: pyt
I have checked the version of python executable and the path from where the library is getting used:
import sys
sys.executable # to know the version of executable used
sys.path # to know from which path library is getting imported.
And then: I have installed the library in jupyter notebook cell by using pip.
pip install matplotlib
After that import started working for me.