jupyter ModuleNotFoundError: No module named matplotlib

跟風遠走 提交于 2019-12-04 10:42:36

open terminal and change the directory to Scripts folder where python installed. Then type the following command and hit enter

pip install matplotlib

Hope this will solve the issue.

I was facing the exact issue. Turns out it was using the system Python version despite me having activated my virtual environment.

This is what eventually worked.

If you are using a virtual environment which has a name say myvenv, first activate it using command:

source activate myenv

Then install module ipykernel using the command:

pip install ipykernel

Finally run (change myenv in code below to the name of your environment):

ipykernel install --user --name myenv --display-name "Python (myenv)" 

Now restart the notebook and it should pick up the Python version on your virtual environment.

Having the same issue, installing matplotlib before to create the virtualenv solved it for me. Then I created the virtual environment and installed matplotlib on it before to start jupyter notebook.

In a Notebook's cell type and execute the code:

import sys  
!{sys.executable} -m pip install --user matplotlib

and reload the kernel

(src: http://jakevdp.github.io/blog/2017/12/05/installing-python-packages-from-jupyter/ )

The issue with me was that jupyter was taking python3 for me, you can always check the version of python jupyter is running on by looking on the top right corner (attached screenshot).

When I was doing pip install it was installing the dependencies for python 2.7 which is installed on mac by default. It got solved by doing:

> pip3 install matplotlib

Check the python version:

$python --version

or

$python3 --version

Try installing "matplotlib" using sudo:

For python version 2.7

$sudo pip install matplotlib

or

For python version 3.x

$sudo pip3 install matplotlib
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!