这适用于所有想要使用最新 Qt4 和 Python 3.4.x 构建 PyQt4 的人。
从这里下载 Visual Studio 2010:http:
//download.cnet.com/Microsoft-Visual-Studio-2010-Ultimate/3000-2383_4-75450998.html
然后安装它。
从这里下载 SIP 源代码(在我的例子中是 4.19.5 版):
https ://www.riverbankcomputing.com/software/sip/download
从这里下载 PyQt4 源代码(在我的例子中是 4.12.1 版):
https ://www.riverbankcomputing.com/software/pyqt/download
在 \Users\your_username\Desktop\compilation\ 中提取 SIP 和 PyQt .zip 存档
从这里下载最新的 Qt 4.x(vs2010 版本)安装程序:http:
//download.qt.io/archive/qt/
安装 Qt(在我的例子中是 qt-opensource-windows-x86-vs2010-4.8.6.exe)。
打开一个命令提示符(在所有过程中都使用这个)并执行以下命令:
cd \Users\<your_username>\Desktop\compilation\sip-4.19.5
python configure.py
"C:\Qt\4.8.6\bin\qtvars.bat"
在输出中记下 QMAKESPEC 值,在我的情况下为 win32-msvc2010,然后稍后在 PyQt4 configure-ng 脚本的 --spec 选项中使用它。
如果当前目录已经改变,再次执行:
cd \Users\<your_username>\Desktop\compilation\sip-4.19.5
现在,如果您使用 64 位版本的 Python,请执行:
"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat"
否则,如果您使用 32 位版本的 Python 执行:
"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\vcvars32.bat"
nmake
nmake install
cd \Users\<your_username>\Desktop\compilation\PyQt4_gpl_win-4.12.1
现在在 --spec 选项中使用以前的 QMAKESPEC 值:
python configure-ng.py --spec win32-msvc2010
nmake
nmake install
就这样 ;-)
注意:在某些情况下,为了避免这个错误
ImportError: DLL load failed: The specified procedure could not be found.
有必要从复制 .dll 文件
C:\Qt\4.8.6\bin
至
C:\Python34\Lib\site-packages\PyQt4