我正在尝试为 Python 安装 matplotlib 库。安装没问题,但是当我在 Python 中导入 pylab(例如 import pylab as p)时出现以下错误。
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/mathtext.py", line 61, in <module>
import matplotlib._png as _png
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/_png.so, 2): Symbol not found: _png_set_longjmp_fn
Referenced from: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/_png.so
Expected in: flat namespace in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/_png.so
Google 搜索表明链接错误(不查找 "_png_set_longjmp_fn" )与 png 库的 32/64 位编译问题有关。
我尝试根据库中的 README.osx 文件重新安装 matplotlib,但未修复。我发现的其他方法没有解决它。另外,我检查了这些库是用 32 位还是 64 位编译的。相关的二进制文件支持两者(通用二进制文件),如下所示。
>file /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/_png.so
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/_png.so: Mach-O universal binary with 2 architectures
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/_png.so (for architecture i386): Mach-O bundle i386
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/_png.so (for architecture x86_64): Mach-O 64-bit bundle x86_64
>file /Library/Frameworks/libpng.framework/Versions/Current/libpng
/Library/Frameworks/libpng.framework/Versions/Current/libpng: Mach-O universal binary with 2 architectures
/Library/Frameworks/libpng.framework/Versions/Current/libpng (for architecture x86_64): Mach-O 64-bit dynamically linked shared library x86_64
/Library/Frameworks/libpng.framework/Versions/Current/libpng (for architecture i386): Mach-O dynamically linked shared library i386
我的 OS X 版本是 Lion 10.7.4。你对这个问题有什么想法吗?谢谢!!!