2016-07-24 222 views
0

我已经搜遍了互联网,为这个问题提供了一个简洁的答案,但似乎找不到一个。我使用python 2的jupyter,并试图导入matplotlib.pyplot无济于事。 这是我运行的代码:不能在jupyter中导入matplotlib

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的,和森蚺导航仪(基本上更新的一切,我可以想到)并重新启动一切,我仍然得到这个错误。

道歉,如果这是简单的我已经错过了,但我不能解密这些错误消息的一些能力。

预先感谢您。

回答

0

这是“导致从Enthought树冠分布numpy的与您的蟒蛇env和matplotlib的numpy的相互冲突很可能对enthought numpy的建成,但运行针对畅达一个(或反之亦然...)

最简单的修复方法是卸载enthought(或conda)并只使用一个。如果它存在,更难/更复杂的修复方法是将python从你的sys.path & PythonPath中踢出。

+0

非常感谢。这已经让我烦恼了好几个月。 –