繁体   English   中英

从 PyQt4 导入 QtGui 时找不到图像错误

[英]Image not found error when importing QtGui from PyQt4

我在 Mac OS X 10.5 上安装了 ActivePython 2.7。 这样做的主要原因是使用 pypm,package 管理器。 但是,在安装 ActivePython 并设置 my.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 上如此不同?

确保 python 和 qt 具有相同的架构(32 位与 64 位)

对于 mathplot 看起来像一个不同的 g++ 用于编译 python 和 mathplot

你试过股票 osx python 吗?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM