python导入matplotlib包出错_导入matplotlib.pyplot时出错

When I run import matplotlib.pyplot as plt, I get the following error message:

---------------------------------------------------------------------------

ImportError Traceback (most recent call last)

in ()

----> 1 import matplotlib.pyplot

/Library/Python/2.7/site-packages/matplotlib/pyplot.py in ()

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 ()

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 ()

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 ()

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 ()

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. My /Library/Python/2.7/site-packages/easy-install.pth is as following:

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? I have homebrew installed, am running the Enthought Python Distribution, and am running 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).

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值