I'm an ubuntu 16.4 user and I installed anaconda3 and using both python2 and python3 kernels.
>>>jupyter kernelspec list Available kernels: python2 /home/peterkim/.local/share/jupyter/kernels/python2 python3 /home/peterkim/anaconda3/share/jupyter/kernels/python3
and.. the problem was that I don't know where/how to install packages in order to for my python2 jupyter notebook not to make error 'no module named ...'.
I tried pip install matplotlib and conda install matplotlib and I also appended '/home//anaconda2/pkgs' to the sys.path.
(I also installed anaconda2 in search of the way of using parallel kernels. After I realised that anaconda2 was not needed. but I didn't uninstall it.)

When using python3 version of jupyter (pip3 install jupyter), matplotlib has to be installed using pip3: pip3 install matplotlib
For those still looking for a solution, especially using virtualenv, this worked for me:
1 - Inside your project directory, create a virtual environment. You may have to install virtualenv in case you don't have it
virtualenv myenv --python=python3.7
2 - Install matplotlib inside of your virtual env:
pip3 install matplotlib
3 - Install ipykernel inside your virtual env
pip3 install ipykernel
4 - Connect your jupyter kernel to your new environment. You may have to use sudo here
python3 -m ipykernel install --name=myenv
5 - When you start your jupyter lab, you will have the option to select your env, which has matplotlib installed

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With