我已经在MacOSX10.5上安装了ActivePython 2.7。这样做的主要原因是使用pypm,包管理器。但是,在安装ActivePython并将我的.bash_profile文件设置为使用该版本的Python后,我遇到了很多使用pypm安装的库的问题。要安装所有这些模块,我只需输入
pypm install <package-name>这就是我获得matplotlib,PyQt4,PIL等的方法。问题是所有这些文件的安装似乎都没有问题,它们将正确的.pth和.so文件放入正确的站点包文件夹中,并且基本导入工作正常。但是我得到了以下错误。
首先,以下是我在机器上检查Python时看到的内容:
new-host:site-packages ely$ which python
/usr/local/bin/python
new-host:site-packages ely$ ls -l /usr/local/bin/python
lrwxr-xr-x 1 root wheel 60 May 25 22:15 /usr/local/bin/python -> /Library/Frameworks/Python.framework/Versions/2.7/bin/python接下来,我调用Python并尝试导入内容。
new-host:site-packages ely$ python
ActivePython 2.7.1.4 (ActiveState Software Inc.) based on
Python 2.7.1 (r271:86832, Feb 7 2011, 11:33:10)
[GCC 4.2.1 (Apple Inc. build 5664)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import PyQt4
>>> from PyQt4 import QtGui
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: dlopen(PyQt4/QtGui.so, 2): Library not loaded: QtGui.framework/Versions/4/QtGui
Referenced from: /Users/ely/Library/Python/2.7/lib/python/site-packages/PyQt4/QtGui.so
Reason: image not found因此,上面显示了PyQt4导入没有任何抱怨,但是当我尝试使用任意子模块时,我得到了“image not found”错误。再举一个例子,这里是标准的matplotlib。
>>> import matplotlib
>>> import matplotlib.pyplot as plt
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "matplotlib/pyplot.py", line 23, in <module>
from matplotlib.figure import Figure, figaspect
File "matplotlib/figure.py", line 16, in <module>
import artist
File "matplotlib/artist.py", line 6, in <module>
from transforms import Bbox, IdentityTransform, TransformedBbox, TransformedPath
File "matplotlib/transforms.py", line 34, in <module>
from matplotlib._path import affine_transform
ImportError: dlopen(matplotlib/_path.so, 2): Symbol not found: __ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
Referenced from: /Users/ely/Library/Python/2.7/lib/python/site-packages/matplotlib/_path.so
Expected in: dynamic lookup
>>> from matplotlib import pyplot
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "matplotlib/pyplot.py", line 23, in <module>
from matplotlib.figure import Figure, figaspect
File "matplotlib/figure.py", line 16, in <module>
import artist
File "matplotlib/artist.py", line 6, in <module>
from transforms import Bbox, IdentityTransform, TransformedBbox, TransformedPath
File "matplotlib/transforms.py", line 34, in <module>
from matplotlib._path import affine_transform
ImportError: dlopen(matplotlib/_path.so, 2): Symbol not found: __ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
Referenced from: /Users/ely/Library/Python/2.7/lib/python/site-packages/matplotlib/_path.so
Expected in: dynamic lookup对为什么pypm安装的版本如此有问题有什么想法吗?我已经在我的Ubuntu工作电脑上使用ActivePython和pypm很长一段时间了,从来没有遇到过这些问题。我用pypm安装的所有东西都运行得很好。为什么在Mac上会有这么大的不同?
发布于 2011-05-27 23:27:07
确保python和qt具有相同的架构(32位与64位)
因为mathplot看起来像是用来编译python和mathplot的不同的g++
你有没有尝试过普通的osx python?
https://stackoverflow.com/questions/6146834
复制相似问题