0

当我运行时import matplotlib.pyplot as plt,我收到以下错误消息:

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

/Library/Python/2.7/site-packages/matplotlib/pyplot.py in <module>()
     21 from matplotlib.cbook import dedent, silent_list, is_string_like, is_numlike
     22 from matplotlib import docstring
---> 23 from matplotlib.figure import Figure, figaspect
     24 from matplotlib.backend_bases import FigureCanvasBase
     25 from matplotlib.image import imread as _imread

/Library/Python/2.7/site-packages/matplotlib/figure.py in <module>()
     16 import artist
     17 from artist import Artist, allow_rasterization
---> 18 from axes import Axes, SubplotBase, subplot_class_factory
     19 from cbook import flatten, allequal, Stack, iterable, is_string_like
     20 import _image

/Library/Python/2.7/site-packages/matplotlib/axes.py in <module>()
     12 import matplotlib.artist as martist
     13 from matplotlib.artist import allow_rasterization
---> 14 import matplotlib.axis as maxis
     15 import matplotlib.cbook as cbook
     16 import matplotlib.collections as mcoll

/Library/Python/2.7/site-packages/matplotlib/axis.py in <module>()
      8 from matplotlib.artist import allow_rasterization
      9 import matplotlib.cbook as cbook
---> 10 import matplotlib.font_manager as font_manager
     11 import matplotlib.lines as mlines
     12 import matplotlib.patches as mpatches

/Library/Python/2.7/site-packages/matplotlib/font_manager.py in <module>()
     50 import matplotlib
     51 from matplotlib import afm
---> 52 from matplotlib import ft2font
     53 from matplotlib import rcParams, get_configdir
     54 from matplotlib.cbook import is_string_like

ImportError: dlopen(/Library/Python/2.7/site-packages/matplotlib/ft2font.so, 2): Library not loaded: /opt/local/lib/libfreetype.6.dylib
  Referenced from: /Library/Python/2.7/site-packages/matplotlib/ft2font.so
  Reason: image not found

/Library/Python/2.7/site-packages/setuptools.pth的是这样的:/Library/Frameworks/EPD64.framework/Versions/7.3/Python。我/Library/Python/2.7/site-packages/easy-install.pth的如下:

import sys; sys.__plen = len(sys.path)
./pip-1.2.1-py2.7.egg
/Library/Frameworks/EPD64.framework/Versions/7.3/Python
./pudb-2012.3-py2.7.egg
./Pygments-1.5-py2.7.egg
./urwid-1.0.2-py2.7-macosx-10.8-intel.egg
import sys; new=sys.path[sys.__plen:]; del sys.path[sys.__plen:]; p=getattr(sys,'__egginsert',0); sys.path[p:p]=new; sys.__egginsert = p+len(new)

我应该matplotlib.pyplot正确导入什么?我安装了自制软件,正在运行 Enthought Python 发行版,并且正在运行 OSX。

4

1 回答 1

2

我修好了它!我所做的如下:我删除(在备份后)我系统的站点包文件夹(/Library/Python/2.7/site-packages)中的 matplotlib 文件夹。

于 2012-11-08T17:25:02.900 回答