我在使用matplotlib时收到此错误

时间:2012-10-28 16:09:05

标签: python macos numpy matplotlib scipy

我在python命令提示符下键入此错误:import matplotlib.pyplot as plt

Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    import matplotlib.pyplot as plt
  File "/Library/Python/2.7/site-packages/matplotlib-1.3.x-py2.7-macosx-10.8-intel.egg/matplotlib/pyplot.py", line 97, in <module>
    _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
  File "/Library/Python/2.7/site-packages/matplotlib-1.3.x-py2.7-macosx-10.8-intel.egg/matplotlib/backends/__init__.py", line 25, in pylab_setup
    globals(),locals(),[backend_name])
  File "/Library/Python/2.7/site-packages/matplotlib-1.3.x-py2.7-macosx-10.8-intel.egg/matplotlib/backends/backend_macosx.py", line 21, in <module>
    from matplotlib.backends import _macosx
ImportError: dlopen(/Library/Python/2.7/site-packages/matplotlib-1.3.x-py2.7-macosx-10.8-intel.egg/matplotlib/backends/_macosx.so, 2): Library not loaded: /System/Library/Frameworks/CoreText.framework/Versions/A/CoreText
  Referenced from: /Library/Python/2.7/site-packages/matplotlib-1.3.x-py2.7-macosx-10.8-intel.egg/matplotlib/backends/_macosx.so
  Reason: image not found

有人可以建议我,我该如何解决这个问题?我用这个shell脚本安装了所有的包

https://github.com/fonnesbeck/ScipySuperpack

我有什么遗失的吗?任何其他配置?

2 个答案:

答案 0 :(得分:2)

我正在为OSX 10.7.4借调andershqst:

转到此目录:

cd /System/Library/Frameworks

验证此路径是否存在:

ls /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/CoreText.framework/Versions/A/CoreText

创建此软链接:

sudo ln -s /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/CoreText.framework Coretext.framework

然后测试你的修补程序as described in this tutorial

答案 1 :(得分:0)

我使用ScipySuperpack遇到了同样的问题,并通过以下方式解决了这个问题。

打开终端并找到CoreText.framework文件的路径

sudo find / -name "CoreText.framework"

从定位路径的CoreText文件到ImportError中的路径创建符号链接

sudo ln -s path_located path_where_it_is_missing

此时我遇到了另一个构建错误,因为我运行OSX 10.7.5(10.8是你目前从ScipySuperpack页面获得的那个)在这种情况下,从here获取ScipySuperpack并回答'是'提示时'是否从克隆到此计算机的存储库进行安装(如果不确定,请回答否)? (Y / N)'