1

I'm Unable to load matplotlib in Jupyter Notebook but woking fine in python command line shell,

Is there anything I need to configure to make it working?

Following is the error I'm getting in Jupyter Notebook

---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-99ba79ecbbfb> in <module>()
----> 1 from matplotlib import pyplot as plt
ImportError: No module named matplotlib

And in command line I can access it like the following:

Python 3.7.3 (default, Mar 27 2019, 23:47:09) 
[Clang 10.0.0 (clang-10001044.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from matplotlib import pyplot as plt
>>> 
asked Aug 9, 2019 at 11:30
2
  • have you installed jupyter notebook using pip3? Commented Aug 9, 2019 at 11:41
  • @Ruturaj - I followed https://jupyter.org/install pip3 install jupyterlab and pip3 install jupyter Commented Aug 9, 2019 at 12:31

3 Answers 3

3

Seems like it's working now I ran the following command as specified here

python3 -m pip install ipykernel
python3 -m ipykernel install --user

Thanks.

answered Aug 9, 2019 at 14:41

Comments

0

One way is to check if you installed matplotlib using pip3 (if you used pip3 to install jupyter notebook, which looks like is your case).

Another way is to add the path of site-wide packages (where of course matplotlib is installed). In your Jupyter notebook console:

import sys
PATH = '/usr/lib64/python3.7/site-packages/'
sys.path.append(PATH)
answered Aug 9, 2019 at 11:48

5 Comments

I have installed jupyter notebook using pip3 but it's showing the following in the about page The version of the notebook server is: 5.7.8 The server is running on this version of Python: Python 2.7.16 (default, Mar 4 2019, 09:01:38) [GCC 4.2.1 Compatible Apple LLVM 10.0.0 (clang-10001145.5)], How I can make it working as python3. I created the new book as python3 but still it's executing as python2.7
can you see? jupyter kernelspec list
Available kernels: python2 /usr/local/share/jupyter/kernels/python2 python3 /usr/local/share/jupyter/kernels/python3
install with: python3 -m pip install --upgrade pip && python3 -m pip install jupyter - including ipython - pip3 install --upgrade pip jupyter ipython
still it's same
0

Notebook is launched from another virtual python environment.

You can check paths to python interpreters, that run your notebook and interactive shell:

import sys
print(sys.executable)

I'm sure, they will be different.

answered Aug 9, 2019 at 12:00

1 Comment

Yes it's different /usr/local/opt/python@2/bin/python2.7 but I created this book as python3 also I tried to change it to python3 from the kernel menu. How i can make it working as python3

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.