我有一个类似的问题。具体来说,我想要在一个使用不兼容版本的Qt的应用程序中的嵌入式Python解释器中使用PyQt。主要应用程序使用了两个Qt DLL:QtCore.dll和QtGui.dll。
当我从嵌入式Python解释器中加载PyQt时,我会收到一个错误:
ImportError: DLL load failed: The specified procedure could not be found.
这件事情发生在这条线上:
from PyQt4 import QtGui
问题在于一旦一个不兼容的QtGui.dll加载到主应用程序的进程空间中,对QtGui.dll的任何引用(例如来自QtGui.pyd文件)都是不正确的。
接下来发生的事情,我并不以此为傲。
First I renamed QtGui4.dll
in the PyQt distribution to QtGuiX.dll
and then renamed the QtCore4.dll
to QtCoreX.dll
. Notice that the
renaming maintained the same number of characters, this is important.
Next I opened the file QtGui.pyd
in Notepad++, and replaced all
plain-text references of QtGui4.dll
to QtGuiX.dll
and from
QtCore4.dll
to QtCoreX.dll
. I repeated the process for the files:
QtCore.pyd
, QtGuiX.dll
and QtCoreX.dll
.
Finally I checked that my PyQt test application still worked. It did!
Then I tried running the PyQt test application from the embedded
Python interpreter, and it worked as well.
So, it seems to works in a couple of trivial cases. I expect that I
need to repeat the process for all DLLs and PYDs in the PyQt
distribution.
这可能不是正确的做事方式,但我想不到任何具体的理由会导致它爆炸(除非我更改文件名的长度)。
将这归功于论坛中的其他人鼓舞了这个可怕的故事。