我知道这个问题之前已经有人问过了。我按照那里的答案所给的指示操作,但是并没有解决我的问题(而且我没有足够的声望来在那个帖子中发表评论)。无论如何,以下是发生的情况:
我尝试执行:
import matplotlib.pyplot
作为回报,我得到:
Traceback (most recent call last):
File "/Users/russellrichie/anaconda/lib/python2.7/site-packages/IPython/core/interactiveshell.py", line 3032, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-3-eff513f636fd>", line 1, in <module>
import matplotlib.pyplot as plt
File "/Users/russellrichie/anaconda/lib/python2.7/site-packages/matplotlib/pyplot.py", line 27, in <module>
import matplotlib.colorbar
File "/Users/russellrichie/anaconda/lib/python2.7/site-packages/matplotlib/colorbar.py", line 34, in <module>
import matplotlib.collections as collections
File "/Users/russellrichie/anaconda/lib/python2.7/site-packages/matplotlib/collections.py", line 27, in <module>
import matplotlib.backend_bases as backend_bases
File "/Users/russellrichie/anaconda/lib/python2.7/site-packages/matplotlib/backend_bases.py", line 56, in <module>
import matplotlib.textpath as textpath
File "/Users/russellrichie/anaconda/lib/python2.7/site-packages/matplotlib/textpath.py", line 22, in <module>
from matplotlib.mathtext import MathTextParser
File "/Users/russellrichie/anaconda/lib/python2.7/site-packages/matplotlib/mathtext.py", line 63, in <module>
import matplotlib._png as _png
ImportError: dlopen(/Users/russellrichie/anaconda/lib/python2.7/site-packages/matplotlib/_png.so, 2): Library not loaded: libpng15.15.dylib
Referenced from: /Users/russellrichie/anaconda/lib/python2.7/site-packages/matplotlib/_png.so
Reason: image not found
我的Python版本:
2.7.7 |Anaconda 2.0.1 (x86_64)| (default, Jun 2 2014, 12:48:16) [GCC 4.0.1 (Apple Inc. build 5493)]
编辑:
cel的建议奏效了!我刚刚尝试了“conda remove matplotlib”,“pip install matplotlib”,然后是“conda install matplotlib”,咔嚓!天哪,你们不知道这个问题困扰了我多久。感谢你们所有人。
matplotlib
的?尝试用conda remove matplotlib
和pip uninstall matplotlib
卸载它,然后再尝试使用conda install matplotlib
解决这个问题。 - celbrew unlink libpng
然后brew install libpng
) ,然后再执行conda remove matplotlib
和conda install matplotlib
,这样%matplotlib inline
就不再生成任何错误了。 - Alexis Perrier