我已经在互联网上搜索了这个问题的简明答案,但似乎无法找到一个。我正在使用jupyter for python 2并且我试图导入matplotlib.pyplot无济于事。 这是我正在运行的代码:
import matplotlib.pyplot as plt
%matplotlib inline
我收到的错误信息是:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-5-385145dcc870> in <module>()
----> 1 import matplotlib.pyplot as plt
2 get_ipython().magic(u'matplotlib inline')
/Users/mbhall88/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/matplotlib/__init__.py in <module>()
120 # cbook must import matplotlib only within function
121 # definitions, so it is safe to import from it here.
--> 122 from matplotlib.cbook import is_string_like, mplDeprecation, dedent, get_label
123 from matplotlib.compat import subprocess
124 from matplotlib.rcsetup import (defaultParams,
/Users/mbhall88/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/matplotlib/cbook.py in <module>()
31 from weakref import ref, WeakKeyDictionary
32
---> 33 import numpy as np
34 import numpy.ma as ma
35
/Users/mbhall88/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/numpy/__init__.py in <module>()
183 return loader(*packages, **options)
184
--> 185 from . import add_newdocs
186 __all__ = ['add_newdocs',
187 'ModuleDeprecationWarning',
/Users/mbhall88/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/numpy/add_newdocs.py in <module>()
11 from __future__ import division, absolute_import, print_function
12
---> 13 from numpy.lib import add_newdoc
14
15 ###############################################################################
/Users/mbhall88/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/numpy/lib/__init__.py in <module>()
15 from .ufunclike import *
16
---> 17 from . import scimath as emath
18 from .polynomial import *
19 #import convertcode
ImportError: cannot import name scimath
我有更新matplotlib,numpy,scimath,scipy和anaconda导航器(基本上更新了我能想到的一切)并重新启动了所有内容,但我仍然遇到此错误。
道歉,如果这很简单,我已经错过了,但我不能解密其中的一些错误信息。
提前谢谢。
答案 0 :(得分:0)
这是因为你的Enthought冠层分布中的numpy与你的anaconda env中的numpy相冲突,而matplotlib很可能是针对enthought numpy构建的,但是对抗conda one(反之亦然......)
最简单的解决方法是卸载enthought(或conda)并且只使用一个。更难/更麻烦的解决方法是将你的syshpath&amp; PythonPath(如果存在)。