2016-07-24 49 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

非常感謝。這已經讓我煩惱了好幾個月。 –

相關問題