我在这个 windows 7 32 位上安装了 python3.3 x86(官方 python.org 安装程序)
然后从这里为 python3.3 windows x86 安装 PyQt4-4.10 PyQt4-4.10-gpl-Py3.3-Qt5.0.1-x32-2.exe ,也是官方安装程序,完整的 PyQt4 安装(包括 Qt 运行时)
我仔细检查了 python 和 PyQt4 都在 $PATH 上
但似乎我可以导入一些包(例如 QtCore)但不能导入其他包(例如 QtGui)
虽然他们并肩走在同一条路上
>>> from PyQt4 import QtCore
>>> QtCore.__file__
'C:\\Python33\\lib\\site-packages\\PyQt4\\QtCore.pyd'
>>> from PyQt4 import QtGui
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
from PyQt4 import QtGui
ImportError: DLL load failed: The specified module could not be found.
>>> import os
>>> os.path.exists('C:\\Python33\\lib\\site-packages\\PyQt4\\QtGui.pyd')
True
>>> from PyQt4 import Qt
>>> from PyQt4 import QtXml
>>> from PyQt4 import QtNetwork
>>> from PyQt4 import QtDesigner
Traceback (most recent call last):
File "<pyshell#8>", line 1, in <module>
from PyQt4 import QtDesigner
ImportError: DLL load failed: The specified module could not be found.
>>> os.path.exists('C:\\Python33\\lib\\site-packages\\PyQt4\\QtDesigner.pyd')
True
最佳答案
Qt5Gui.dll 依赖于 D3dCOMPILER_43.dll,它是 DirectX 的一部分。您可以使用 DirectX End-User Runtime Web Installer 更新您的安装。 .
关于PyQt4 不能导入 QtGui 但可以导入 QtCore,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15708919/