I am importing matplotlib from Jupyter Notebook but get the following error.
ImportError: No module named matplotlib
Settings:
Python 2
MacBook
conda: 4.3.30
After run
conda list
it got:
ipykernel 4.6.1
ipython 5.3.0
matplotlib 2.0.2 np112py36_0
matplotlib 2.1.1
Some commends I tried but failed
1.
sudo apt-get install python-matplotlib
and shows
sudo: apt-get: command not found
2.
sudo apt-get install python3-matplotlib
and shows
sudo: apt-get: command not found
commends 1 and 2 are from this site
ImportError: No module named matplotlib with matplotlib installed
3.
pip install matplotlib
and shows
Requirement already satisfied: matplotlib in ./anaconda/lib/python3.6/site-packages Requirement already satisfied: pytz in ./anaconda/lib/python3.6/site-packages (from matplotlib) Requirement already satisfied: cycler>=0.10 in ./anaconda/lib/python3.6/site-packages (from matplotlib) Requirement already satisfied: numpy>=1.7.1 in ./anaconda/lib/python3.6/site-packages (from matplotlib) Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in ./anaconda/lib/python3.6/site-packages (from matplotlib) Requirement already satisfied: six>=1.10 in ./anaconda/lib/python3.6/site-packages (from matplotlib) Requirement already satisfied: python-dateutil>=2.0 in ./anaconda/lib/python3.6/site-packages (from matplotlib)
commend 3 from this website
ImportError: No module named matplotlib.pyplot
Update:
run this
pip2 install matplotlib
it was successfully installed like this
Collecting matplotlib Downloading matplotlib-2.1.1-cp27-cp27m... ... Successfully built subprocess32 Installing collected packages: subprocess32, six, python-dateutil, backports.functools-lru-cache, pyparsing, cycler, numpy, pytz, matplotlib Successfully installed backports.functools-lru-cache-1.4 cycler-0.10.0 matplotlib-2.1.1 numpy-1.13.3 pyparsing-2.2.0 python-dateutil-2.6.1 pytz-2017.3 six-1.11.0 subprocess32-3.2.7
then restart Anaconda and Jupyter, and it was not imported.