jupyter notebook import error: no module named ‘matplotlib’

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.)


thank you for helping me in advance..!


I’d recommend reading through here:


I had the same problem after installing a Python 2.7 environment inside my Anaconda3 installation. I’m not sure which command I used to create the environment, but it actually didn’t install all the optional packages that are usually bundled with Anaconda (like matplotlib, numpy, …). But that’s not a big issue, you can easily install additional packages with pip as follows:

First, list your conda environments:

C:UsersFelix>conda info --envs
# conda environments:
ipykernel_py2            D:Anacondaenvsipykernel_py2
root                  *  D:Anaconda

Next, activate your python 2 environment using source activate <env> (Linux/OSX) or activate <env> (Windows):

C:UsersFelix>activate ipykernel_py2

(ipykernel_py2) C:UsersFelix>

Finally, use pip to install the required packages:

(ipykernel_py2) C:UsersFelix>pip install matplotlib
Collecting matplotlib
Successfully installed matplotlib-2.0.0

Hope that this helps.

Leave a Reply

Your email address will not be published. Required fields are marked *