从 PyQt4 导入 QtGui 时出现图像未找到错误
我已经在 Mac OS X 10.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 导入时没有任何抱怨,但是当我尝试使用任何子模块时,我收到“未找到图像”错误。另一个例子,这是标准的 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 上的情况如此不同?
I have installed ActivePython 2.7 on Mac OS X 10.5. The main reason for this is to use pypm, the package manager. However, after installing ActivePython and setting up my .bash_profile file to use that version of Python, I encounter a lot of problems with the pypm-installed libraries. To install all of these modules, I just type
pypm install <package-name>
and this is how I got matplotlib, PyQt4, PIL, etc. The problem is that all of these appear to install with no problems, they place the correct .pth and .so files into the correct site-packages folder, and basic imports work fine. But I get the following errors.
First, here is what I see when checking for Python on my machine:
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
Next, I invoke Python and attempt to import things.
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
So the above shows that PyQt4 imports with no complaints, but then I get the 'image not found' error when I try to use any of the sub-modules. For another example, here is the standard 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
Any thoughts on why the pypm-installed versions are so problematic? I've used ActivePython and pypm on my Ubuntu work computer for a long time and never had any of these issues. Everything I've ever installed with pypm has worked beautifully. Why is it so different on Mac?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
确保 python 和 qt 具有相同的体系结构(32 位与 64 位),
因为 mathplot 看起来像是用于编译 python 和 mathplot 的不同 g++
您是否尝试过使用 Stock osx python?
Make sure python and qt have same architecture (32bit vs 64bit)
for mathplot looks like a different g++ used to compile python and mathplot
have you tried with stock osx python?