简体   繁体   English

导入matplotlib.pyplot时出错

[英]Error importing matplotlib.pyplot

When I run import matplotlib.pyplot as plt , I get the following error message: 当我运行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

My /Library/Python/2.7/site-packages/setuptools.pth is this: /Library/Frameworks/EPD64.framework/Versions/7.3/Python . 我的/Library/Python/2.7/site-packages/setuptools.pth是这样的: /Library/Frameworks/EPD64.framework/Versions/7.3/Python My /Library/Python/2.7/site-packages/easy-install.pth is as following: 我的/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)

What should I to import matplotlib.pyplot correctly? 我应该如何正确导入matplotlib.pyplot I have homebrew installed, am running the Enthought Python Distribution, and am running OSX. 我已经安装了自制软件,正在运行Enthought Python Distribution,并且正在运行OSX。

I fixed it! 我修好了它! What I did was the following: I deleted (after making a backup) the matplotlib folder in my system's site-packages folder ( /Library/Python/2.7/site-packages ). 我做的是以下内容:我删除了(在备份后)我系统的site-packages文件夹( /Library/Python/2.7/site-packages )中的matplotlib文件夹。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM