Python Jupyter在导入matplotlib时出现导入错误

Python Jupyter在导入matplotlib时出现导入错误,python,matplotlib,ipython,jupyter,enthought,Python,Matplotlib,Ipython,Jupyter,Enthought,我刚刚尝试集成到Jupyter,我已经使用Anaconda很长一段时间了 尝试在IPython笔记本中导入matplotlib时 import matplotlib.pyplot as plt %matplotlib inline 我得到这个错误: ImportError Traceback (most recent call last) <ipython-input-2-385145dcc870> in <modu

我刚刚尝试集成到Jupyter,我已经使用Anaconda很长一段时间了

尝试在IPython笔记本中导入matplotlib时

import matplotlib.pyplot as plt
%matplotlib inline
我得到这个错误:

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
ImportError回溯(最近一次调用)
在()
---->1将matplotlib.pyplot作为plt导入
2 get_ipython().magic(u'matplotlib inline')
ImportError:没有名为matplotlib.pyplot的模块

我认为如果使用conda,则应在终端类型中安装
matplotlib
库:

# 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
此代码取自。希望这有帮助

谢谢


迈克尔

我也面临同样的问题。然后我使用下面的命令将matplotlib库安装到我的虚拟环境中

pip install matplotlib

然后我可以将matplotlib导入jupyter笔记本。

rm-rf~/Library/enthund/
,因为删除Canopy
应用程序不会删除主目录中的文件夹。我当时就把它拆了。现在,当再次尝试matplotlib时,我得到了这个--在编辑中。