1

I'm just now trying to integrate to Jupyter and I have been using Anaconda for a long while now.

When trying to import the matplotlib in the IPython Notebook,

import matplotlib.pyplot as plt
%matplotlib inline

I get this error:

ImportError                               Traceback (most recent call last)
<ipython-input-2-385145dcc870> in <module>()
----> 1 import matplotlib.pyplot as plt
      2 get_ipython().magic(u'matplotlib inline')

ImportError: No module named matplotlib.pyplot
3
  • 1
    rm -rf ~/Library/Enthought/ Commented Mar 31, 2016 at 22:01
  • Because removing the Canopy Application does not remove the folders in your home directory. support.enthought.com/entries/… Commented Mar 31, 2016 at 22:02
  • I removed it then. Now when trying matplotlib again, i get this -- in edit. Commented Mar 31, 2016 at 22:21

2 Answers 2

1

I faced the same problem. Then I used folllowing command to install matplotlib library to my virtual environment.

pip install matplotlib

Then I could import matplotlib to jupyter notebook.

Sign up to request clarification or add additional context in comments.

Comments

0

I think you should install matplotlib library if using conda then in terminal type:

# create a new environment with the required packages
conda create -n "matplotlib_build" python=3.5 numpy python-dateutil pyparsing pytz tornado cycler tk libpng zlib freetype
activate matplotlib_build
# if you want a qt backend, you also have to install pyqt (be aware that pyqt doesn't mix well if
# you have created the environment with conda-forge already activated...)
conda install pyqt
# this package is only available in the conda-forge channel
conda install -c conda-forge msinttypes

# copy the libs which have "wrong" names
set LIBRARY_LIB=%CONDA_PREFIX%\Library\lib
mkdir lib || cmd /c "exit /b 0"
copy %LIBRARY_LIB%\zlibstatic.lib lib\z.lib
copy %LIBRARY_LIB%\libpng_static.lib lib\png.lib

# Make the header files and the rest of the static libs available during the build
# CONDA_DEFAULT_ENV is a env variable which is set to the currently active environment path
set MPLBASEDIRLIST=%CONDA_PREFIX%\Library\;.

# build the wheel
python setup.py bdist_wheel

This code was taken from https://matplotlib.org/users/installing.html#conda-packages. Hope this helps.

Thanks

Michael

Comments

Your Answer

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.