如何在matplotlib中修复ImportError

时间:2010-06-25 17:57:56

标签: python import matplotlib importerror

我在运行雪豹的mac上编译matplotlib只是为了发现当我导入matplotlib.pyplot时出现以下错误:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/pyplot.py", line 6, in <module>
    from matplotlib.figure import Figure, figaspect
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/figure.py", line 18, in <module>
    from axes import Axes, SubplotBase, subplot_class_factory
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/axes.py", line 12, in <module>
    import matplotlib.axis as maxis
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/axis.py", line 10, in <module>
    import matplotlib.font_manager as font_manager
  File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/font_manager.py", line 52, in <module>
    from matplotlib import ft2font
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/ft2font.so, 2): Symbol not found: _FT_Attach_File
  Referenced from: /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/matplotlib/ft2font.so
  Expected in: dynamic lookup

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

在OS X上构建matplotlib是出了名的,因为链接到系统目录中不匹配的库版本,/ usr / local,/ opt / local,你有什么问题。这就是为什么源代码发行版中有一个README.osx文件,建议您使用分发中提供的make.osx文件来获取和编译库,并针对获取的副本构建matplotlib。