从Pyside导入QtGui时出错

时间:2015-11-21 10:06:25

标签: python pyside

我刚刚下载并安装了PySide,当我尝试从PySide导入QtGui时出现此错误

$ python -c "from PySide import QtGui"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: dlopen(/Library/Python/2.7/site-packages/PySide/QtGui.so, 2): Symbol not found: __ZN7QLayout11adoptLayoutEPS_
  Referenced from: /Library/Python/2.7/site-packages/PySide/QtGui.so
  Expected in: /Library/Frameworks/QtGui.framework/Versions/4/QtGui
 in /Library/Python/2.7/site-packages/PySide/QtGui.so

任何帮助将不胜感激。

2 个答案:

答案 0 :(得分:0)

昨天从pip安装了PySide。 检查&#34; python -c&#34;来自PySide导入QtGui&#34;一切进口都很好。

Firs检查你是否有QtGui.so&#34; /Library/Python/2.7/site-packages/PySide /"目录,导致有。

几个月前尝试从源代码安装PyQt遇到了编译问题:一切看起来都不错,但有些模块(包括QtGui)缺席(无法记住,但问题出在某些配置文件中)。

答案 1 :(得分:0)

尝试从 /Library/Python/2.7/site-packages/PySide/QtCore.so 文件中删除 __ ZN7QLayout11adoptLayoutEPS _

你的代码是正确的: python -c&#34;来自PySide import QtGui&#34; 但问题在于您的操作系统,请从官方网站下载PySide:https://pypi.python.org/packages/f1/32/63872fdc1d9e0de5aa0b05b9d1a17d868851c619cdc6998dd9d853556f1b/PySide-1.2.1.tar.gz#md5=b551d6ff68685013b59e478571f775bf

如果您使用的是Windows,请运行cmd并输入以下命令:

cd <type here the python path>
example: cd C:\Python27

并输入:

python <here the path of the extracted and download pyside file>\setup.py install
example: python C:\users\someuser\pysyde_extractedfiles\setup.py install

如果您使用Mac OS X运行终端并输入:

cd /<you_python_install_dir>
python /<your_extracted_pyside_files_path/setup.py install>
example: cd /opt/python27 && python /tmp/pyside_extracted/setup.py install

如果您使用的是Linux(Ubuntu,Debian,ArchLinux)

wget <here_the_pyside_download_url>
cd /home/<you_username>/<you_extracted_pyside_folder>
python setup.py install

如果您使用python3,请输入:

python3 setup.py install

我希望这可以帮到你!