导入matplotlib不起作用

时间:2015-07-02 11:49:04

标签: python matplotlib

在我的终端窗口中,打开ipython环境,然后输入import matplotlib.pyplot as plt。我这样做的错误信息是:

ImportError                               Traceback (most recent call last)
<ipython-input-1-eff513f636fd> in <module>()
----> 1 import matplotlib.pyplot as plt

/Users/arazipinhas/anaconda/lib/python2.7/site-packages/matplotlib/pyplot.py in <module>()
     25 
     26 import matplotlib
---> 27 import matplotlib.colorbar
     28 from matplotlib import style
     29 from matplotlib import _pylab_helpers, interactive

/Users/arazipinhas/anaconda/lib/python2.7/site-packages/matplotlib/colorbar.py in <module>()
     32 import matplotlib.artist as martist
     33 import matplotlib.cbook as cbook
---> 34 import matplotlib.collections as collections
     35 import matplotlib.colors as colors
     36 import matplotlib.contour as contour

/Users/arazipinhas/anaconda/lib/python2.7/site-packages/matplotlib/collections.py in <module>()
     25 import matplotlib.artist as artist
     26 from matplotlib.artist import allow_rasterization
---> 27 import matplotlib.backend_bases as backend_bases
     28 import matplotlib.path as mpath
     29 from matplotlib import _path

/Users/arazipinhas/anaconda/lib/python2.7/site-packages/matplotlib/backend_bases.py in <module>()
     54 
     55 import matplotlib.tight_bbox as tight_bbox
---> 56 import matplotlib.textpath as textpath
     57 from matplotlib.path import Path
     58 from matplotlib.cbook import mplDeprecation

/Users/arazipinhas/anaconda/lib/python2.7/site-packages/matplotlib/textpath.py in <module>()
     20 from matplotlib.ft2font import FT2Font, KERNING_DEFAULT, LOAD_NO_HINTING
     21 from matplotlib.ft2font import LOAD_TARGET_LIGHT
---> 22 from matplotlib.mathtext import MathTextParser
     23 import matplotlib.dviread as dviread
     24 from matplotlib.font_manager import FontProperties

/Users/arazipinhas/anaconda/lib/python2.7/site-packages/matplotlib/mathtext.py in <module>()
     61 
     62 import matplotlib.colors as mcolors
---> 63 import matplotlib._png as _png
     64 ####################
     65 

ImportError: dlopen(/Users/arazipinhas/anaconda/lib/python2.7/site-packages/matplotlib/_png.so, 2): Library not loaded: @loader_path/../../../libpng15.15.dylib
  Referenced from: /Users/arazipinhas/anaconda/lib/python2.7/site-packages/matplotlib/_png.so
  Reason: image not found

我真的很感激解决这个问题的方法。我想做的就是继续我的物理学,所有这些不断的计算挫折是非常麻烦和烦人的。因此,我应该感谢任何愿意提供帮助的人的快速反应。

2 个答案:

答案 0 :(得分:2)

ImportError: dlopen(/Users/arazipinhas/anaconda/lib/python2.7/site-packages/matplotlib/_png.so, 2):
Library not loaded: @loader_path/../../../libpng15.15.dylib

非常简单:你的matplotlib与libpng15相关联,但是你的运行时找不到它。因此,您可以搜索该文件libpng15.15.dylib。 如果它丢失了,那么您的安装不完整,并且您可能错过了用于构建matplotlib的libPNG版本。

答案 1 :(得分:2)

Continuum最近更新了libpng,导致了这种破坏。很抱歉给您带来不便。

修复此错误的方法是在终端中运行

conda update qt
conda update matplotlib