How to fix ImportError in matplotlib

半世苍凉 提交于 2020-01-06 02:49:13

问题


I compiled matplotlib on a mac running snow leopard only to find that when I import matplotlib.pyplot I get the following error:

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

How do I fix this?


回答1:


Building matplotlib on OS X is notoriously fraught with problems linking to mismatched versions of libraries that can be in the system directories, /usr/local, /opt/local, what have you. That's why there is a README.osx file in the source distribution advising you to use the make.osx file provided in the distribution that fetches and compiles the libraries and builds matplotlib against the fetched copy.



来源:https://stackoverflow.com/questions/3120265/how-to-fix-importerror-in-matplotlib

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!