0
votes

I have downloaded and installed anaconda. But when I run jupyter notebook and import matplotlib , it doesn't work. Below are some commands

which -a python

/home/user/anaconda3/bin/python
/usr/bin/python

which -a jupyter

/home/user/anaconda3/bin/jupyter

I run the notebook as follows

jupyter notebook

I get the below error

 ImportError                               Traceback (most recent call last)
<ipython-input-1-fe07c3ebfee7> in <module>()
      2 # before proceeding further.
      3 from __future__ import print_function
----> 4 import matplotlib.pyplot as plt
      5 import numpy as np
      6 import os

ImportError: No module named 'matplotlib'

Note when I run python through terminal I can import matplotlib , the problem only persist in the browser of ipython notebook after running jupyter.

1
What does the output from sys.path show for the terminal, and the notebook? - Abstracted
Does other packages works well. I think there may be two reasons. First, you start up a wrong kernel corresponding to the Python version which works well in terminal. Second, the system path of Anaconda may be wrong. You can try conda install matpllotlib. - Han Zhengzu
Yes , when I print sys.path , Ipython version prints /usr/lib/python3.5 , but the terminal prints /home/user/anaconda3 . How do fix Ipython to use anaconda one ? I am running jupyter from anaconda installation , why it is referring to the /usr/lib python?? - Tamim Addari

1 Answers

1
votes

It worked after changing /usr/local/share/jupyter/kernels/python3/kernel.json . The path there was /usr/bin/python , changed it to anaconda one.