PyQT5編譯安裝[Python3.6.1 + VS2013 + QT5.5]
- 2020 年 3 月 10 日
- 筆記
原創文章,歡迎轉載。轉載請註明:轉載自 祥的博客
原文鏈接:https://blog.csdn.net/humanking7/article/details/80393070
- 先放資源
- 問題
- 編譯PyQT5
- step1. 安裝SIP
- step2. 下載PyQT源碼
- step3 Python configure.py
- 錯誤3.1: nmake.exe,qmake.exe,mk.exe 不在系統環境中
- 錯誤3.2: 缺少 *.h 和 *.lib 文件 [最後證明這個方法好蠢]
- 錯誤3.3: 協議衝突
- 錯誤3.4: Error: Make sure you have a working sip on your PATH
- 成功 Python configure.py
- step4. nmake
- 錯誤4.1: 又涼了,源碼編譯有問題
- 錯誤4.2: 要禁掉部分組件
- step5. nmake install
- 測試
- 小結
- 乾貨
先放資源
需要環境為:
- VS2013
- Python3.6.1 x86
1.編譯好的sip-4.19.8 編譯好的資源sip:https://download.csdn.net/download/humanking7/10428493
2.編譯好的PyQT5.10.1 編譯好的資源PyQT:https://download.csdn.net/download/humanking7/10428457 已經編譯編譯好了,只需要解壓,cmd
進入後運行nmake install
我的開發環境:
- Windows7 x64
- VS2013
- Qt5.5.0 x86
- Python3.6.1 x86
問題
我一直用的是 Qt5.5.0 開發GUI,而Python不是主要工作語言,所以也沒關注,一直用的Python3.6.1這個版本,最近想對Python進階學習一下,想學一下PyQt,為了讓我原來寫的Python程序人機交互更好一點,方便使用,就瞄上了PyQt。
原因無他,就是有Qt的基礎,而且夠用、效率高於標準庫的Tkinter
但是,網上要麼用pip,要麼是自己編譯
pip3 install PyQT5
但是用pip的好處和壞處都很明顯
- 好處: 方便
- 壞處: 沒辦法知己控制Qt的版本,需要聯網,下載太慢了(這條針對我?)
自己編譯,對於用慣了集成開發環境的我,簡直是噩夢,網上教程又少,而且大家的情況都不一樣,所以我也是摸着石頭過河。
編譯PyQT5
step1. 安裝SIP
Python中使用C/C++模塊有許多工具,大名鼎鼎的有SWIG(英文意思為:豪飲)、SIP(英文意思為:啜飲,小口的喝),還有boost.python等。其中SIP是從SWIG發展而來,專為Python調用C/C++模塊使用的(看SIP的命名就能看出來,很有意思的)。
為了簡單,我就直接調pip安裝了
pip install SIP
後面發現pip
安裝出來的沒法用,見錯誤4,所以用源碼安裝
# Step1.先運行C:Program Files (x86)Microsoft Visual Studio 12.0VCbinvcvars32.bat 配置編譯環境 > "C:Program Files (x86)Microsoft Visual Studio 12.0VCbinvcvars32.bat" # Step2.進入sip源碼目錄 > cd C:sip-4.19.8 # Step3.獲得Makefile文件 > python configure.py # Step4. nmake > nmake # Step5. 安裝 > nmake install
step2. 下載PyQT源碼
網上先下載針對 Qt5.5.0的PyQT5源碼。
PyQT5: https://sourceforge.net/projects/pyqt/files/PyQt5/
我選擇: PyQt-gpl-5.5.zip 編譯好的是針對 Python3.4 我這裡無法使用

step3 Python configure.py
這一步真是 一千個讀者有一千個哈姆雷特 我這一步出現了各種問題,一直用 --verbose
在查找出現的錯誤。
打開cmd,進入PyQt-gpl-5.5.zip解壓後的的目錄
> cd C:PyQt-gpl-5.5 > python configure.py --verbose >> 1.log

錯誤3.1: nmake.exe,qmake.exe,mk.exe 不在系統環境中
添加到系統環境變量的Path
中
D:QtQt5.5.0_x865.5msvc2013bin; C:Program Files (x86)Microsoft Visual Studio 12.0VCbin; C:Program Files (x86)Microsoft SDKsWindowsv7.0ABin
錯誤3.2: 缺少 *.h 和 *.lib 文件 [最後證明這個方法好蠢]
——————————- 最正確的方法補充: 進行nmake
之前,先要在CMD中運行 vcvars32.bat
文件,用來配置nmake
編譯環境 該文件在你的編譯器安裝位置: C:Program Files (x86)Microsoft Visual Studio 12.0VCbinvcvars32.bat
> "C:Program Files (x86)Microsoft Visual Studio 12.0VCbinvcvars32.bat" > nmake #等操作
——————————-
出現了錯誤,打開 1.log
文件
Querying qmake about your Qt installation... Determining the details of your Qt installation... D:QtQt5.5.0_x865.5msvc2013binqmake.exe -spec win32-msvc2010 -o qtdetail.mk qtdetail.pro nmake -f qtdetail.mk release Microsoft (R) 程序維護實用工具 12.00.21005.1 版 版權所有 (C) Microsoft Corporation。 保留所有權利。 "C:Program Files (x86)Microsoft Visual Studio 12.0VCbinnmake.exe" -f qtdetail.mk.Release Microsoft (R) 程序維護實用工具 12.00.21005.1 版 版權所有 (C) Microsoft Corporation。 保留所有權利。 cl -c -nologo -Zc:wchar_t -O2 -MD -GR -W3 -w34100 -w34189 -w44996 -EHsc -DUNICODE -DWIN32 -DQT_NO_DEBUG -DQT_CORE_LIB -DNDEBUG -I. -ID:QtQt5.5.0_x865.5msvc2013include -ID:QtQt5.5.0_x865.5msvc2013includeQtCore -Irelease -ID:QtQt5.5.0_x865.5msvc2013mkspecswin32-msvc2010 -Forelease @C:UsersArthurAppDataLocalTempnmDE14.tmp qtdetail.cpp D:QtQt5.5.0_x865.5msvc2013includeQtCore/qglobal.h(39) : fatal error C1083: 無法打開包括文件: 「cstddef」: No such file or directory NMAKE : fatal error U1077: 「"C:Program Files (x86)Microsoft Visual Studio 12.0VCbincl.EXE"」: 返回代碼「0x2」 Stop. NMAKE : fatal error U1077: 「"C:Program Files (x86)Microsoft Visual Studio 12.0VCbinnmake.exe"」: 返回代碼「0x2」 Stop.
重點在於這句話:
fatal error C1083: 無法打開包括文件: 「cstddef」: No such file or directory
這個cstddef
在 C:Program Files (x86)Microsoft Visual Studio 12.0VCinclude
中,直接將其複製到C:PyQt-gpl-5.5
中 重新運行
> python configure.py --verbose >> 1.log
發現又會缺少其他的 *.h
文件,而且這些文件都在 C:Program Files (x86)Microsoft Visual Studio 12.0VCinclude
中,索性我就把這個目錄下所有的*.h
文件全部拷貝到C:PyQt-gpl-5.5
中
最後發現,會缺少 *.lib
文件,根據提示,我把需要的lib
文件全部複製到C:PyQt-gpl-5.5
中【捂臉,我不知道如何在configure.py
中配置環境啊,那個大佬會,跪求講解】
下圖所示,各種拖進來的lib
和h
文件,很無奈。

錯誤3.3: 協議衝突
> python configure.py --verbose >> 1.log Error: This version of PyQt5 and the commercial version of Qt have incompatible licenses.
這個就要修改configure.py
文件,將其注釋
# Common checks. # if introspecting and target_config.qt_licensee != 'Open Source' and ltype == 'GPL': # error( # "This version of PyQt5 and the commercial version of Qt have " # "incompatible licenses.")
錯誤3.4: Error: Make sure you have a working sip on your PATH
接着運行,發現sip
沒有安裝好?的確如此,我最後用源碼編譯安裝的,pip
還是不靠譜啊
> python configure.py Querying qmake about your Qt installation... Determining the details of your Qt installation... This is the GPL version of PyQt 5.5 (licensed under the GNU General Public License) for Python 3.6.1 on win32. Type 'L' to view the license. Type 'yes' to accept the terms of the license. Type 'no' to decline the terms of the license. Do you accept the terms of the license? yes Found the license file pyqt-gpl.sip. Error: Make sure you have a working sip on your PATH or use the --sip argument to explicitly specify a working sip.
成功 Python configure.py
終於成功了!
> python configure.py Querying qmake about your Qt installation... Determining the details of your Qt installation... This is the GPL version of PyQt 5.5 (licensed under the GNU General Public License) for Python 3.6.1 on win32. Type 'L' to view the license. Type 'yes' to accept the terms of the license. Type 'no' to decline the terms of the license. Do you accept the terms of the license? yes Found the license file pyqt-gpl.sip. Checking to see if the QtGui module should be built... Checking to see if the QtHelp module should be built... Checking to see if the QtMultimedia module should be built... Checking to see if the QtMultimediaWidgets module should be built... Checking to see if the QtNetwork module should be built... Checking to see if the QtOpenGL module should be built... Checking to see if the QtPrintSupport module should be built... Checking to see if the QtQml module should be built... Checking to see if the QtQuick module should be built... Checking to see if the QtSql module should be built... Checking to see if the QtSvg module should be built... Checking to see if the QtTest module should be built... Checking to see if the QtWebKit module should be built... Checking to see if the QtWebKitWidgets module should be built... Checking to see if the QtWidgets module should be built... Checking to see if the QtXml module should be built... Checking to see if the QtXmlPatterns module should be built... Checking to see if the QtDesigner module should be built... Checking to see if the QAxContainer module should be built... Checking to see if the QtDBus module should be built... Checking to see if the _QOpenGLFunctions_2_0 module should be built... Checking to see if the _QOpenGLFunctions_2_1 module should be built... Checking to see if the _QOpenGLFunctions_4_1_Core module should be built... Checking to see if the QtSensors module should be built... Checking to see if the QtSerialPort module should be built... Checking to see if the QtX11Extras module should be built... Checking to see if the QtBluetooth module should be built... Checking to see if the QtMacExtras module should be built... Checking to see if the QtPositioning module should be built... Checking to see if the QtWinExtras module should be built... Checking to see if the QtQuickWidgets module should be built... Checking to see if the QtWebSockets module should be built... Checking to see if the Enginio module should be built... Checking to see if the QtWebChannel module should be built... Checking to see if the QtWebEngineWidgets module should be built... Checking to see if the QtLocation module should be built... Checking to see if the QtNfc module should be built... Checking to see if the dbus support module should be built... DBus v1 does not seem to be installed. Qt v5.5.0 licensed to Builder Qt is being used. The qmake executable is D:QtQt5.5.0_x865.5msvc2013binqmake.exe. Qt is built as a shared library. SIP 4.19.8 is being used. The sip executable is C:Pythonpython3.6.1sip.exe. These PyQt5 modules will be built: QtCore, QtGui, QtHelp, QtMultimedia, QtMultimediaWidgets, QtNetwork, QtPrintSupport, QtQml, QtSql, QtSvg, QtTest, QtWebKit, QtWebKitWidgets, QtWidgets, QtXml, QtXmlPatterns, QtDesigner, QtDBus, QtSensors, QtSerialPort, QtBluetooth, QtPositioning, QtWebSockets, Enginio, QtWebChannel, QtWebEngineWidgets, QtLocation, QtNfc. The PyQt5 Python package will be installed in C:Pythonpython3.6.1Libsite-packages. PyQt5 is being built with generated docstrings. The Designer plugin will be installed in D:/Qt/Qt5.5.0_x86/5.5/msvc2013/plugins/designer. The qmlscene plugin will be installed in D:/Qt/Qt5.5.0_x86/5.5/msvc2013/plugins/PyQt5. The PyQt5 .sip files will be installed in C:Pythonpython3.6.1sipPyQt5. pyuic5, pyrcc5 and pylupdate5 will be installed in C:Pythonpython3.6.1. The interpreter used by pyuic5 is C:Pythonpython3.6.1python.exe. Generating the C++ source for the QtCore module... Embedding sip flags... Generating the .pro file for the QtCore module... Generating the C++ source for the QtGui module... Generating the .pro file for the QtGui module... Generating the C++ source for the QtHelp module... Generating the .pro file for the QtHelp module... Generating the C++ source for the QtMultimedia module... Generating the .pro file for the QtMultimedia module... Generating the C++ source for the QtMultimediaWidgets module... Generating the .pro file for the QtMultimediaWidgets module... Generating the C++ source for the QtNetwork module... Generating the .pro file for the QtNetwork module... Generating the C++ source for the QtPrintSupport module... Generating the .pro file for the QtPrintSupport module... Generating the C++ source for the QtQml module... Generating the .pro file for the QtQml module... Generating the C++ source for the QtSql module... Generating the .pro file for the QtSql module... Generating the C++ source for the QtSvg module... Generating the .pro file for the QtSvg module... Generating the C++ source for the QtTest module... Generating the .pro file for the QtTest module... Generating the C++ source for the QtWebKit module... Generating the .pro file for the QtWebKit module... Generating the C++ source for the QtWebKitWidgets module... Generating the .pro file for the QtWebKitWidgets module... Generating the C++ source for the QtWidgets module... Generating the .pro file for the QtWidgets module... Generating the C++ source for the QtXml module... Generating the .pro file for the QtXml module... Generating the C++ source for the QtXmlPatterns module... Generating the .pro file for the QtXmlPatterns module... Generating the C++ source for the QtDesigner module... Generating the .pro file for the QtDesigner module... Generating the C++ source for the QtDBus module... Generating the .pro file for the QtDBus module... Generating the C++ source for the QtSensors module... Generating the .pro file for the QtSensors module... Generating the C++ source for the QtSerialPort module... Generating the .pro file for the QtSerialPort module... Generating the C++ source for the QtBluetooth module... Generating the .pro file for the QtBluetooth module... Generating the C++ source for the QtPositioning module... Generating the .pro file for the QtPositioning module... Generating the C++ source for the QtWebSockets module... Generating the .pro file for the QtWebSockets module... Generating the C++ source for the Enginio module... Generating the .pro file for the Enginio module... Generating the C++ source for the QtWebChannel module... Generating the .pro file for the QtWebChannel module... Generating the C++ source for the QtWebEngineWidgets module... Generating the .pro file for the QtWebEngineWidgets module... Generating the C++ source for the QtLocation module... Generating the .pro file for the QtLocation module... Generating the C++ source for the QtNfc module... Generating the .pro file for the QtNfc module... Generating the C++ source for the Qt module... Generating the .pro file for the Qt module... Generating the .pro file for pylupdate5... Generating the .pro file for pyrcc5... Generating the pyuic5.bat wrapper... Generating the Qt Designer plugin .pro file... Generating the qmlscene plugin .pro file... Re-writing C:UsersArthurDownloadsCompressedPyQTPyQt-gpl-5.5examplesquicktutorialsextendingchapter6-pluginsChartsqmldir... Generating the top-level .pro file... Generating the Makefiles...
step4. nmake
錯誤4.1: 又涼了,源碼編譯有問題
選擇性放棄了,因為我查了各種文檔以及編譯出來的源碼,包括[PyQt 5.5 Reference Guide]
,都沒有發現這個pyqt5ClassTypeDef
的定義,好蛋疼,所以我瞄準了最新的PyQT5: PyQt5_gpl-5.10.1
,雖然我裝的是QT5.5.0,我打算試一下,把一些組件禁掉,試一試。
> nmake Microsoft (R) 程序維護實用工具 12.00.21005.1 版 版權所有 (C) Microsoft Corporation。 保留所有權利。 cd QtCore && ( if not exist Makefile D:QtQt5.5.0_x865.5msvc2013binqmake.exe C:UsersArthurDownloadsCompressedPyQTPyQ-5.5-py3.6QtCoreQtCore.pro -spec win32-msvc2010 -o Makefile ) && "C:Program Files (x86)Microsoft Visual Studio 12.0VCBINnmake.exe" -f Makefile Microsoft (R) 程序維護實用工具 12.00.21005.1 版 版權所有 (C) Microsoft Corporation。 保留所有權利。 "C:Program Files (x86)Microsoft Visual Studio 12.0VCBINnmake.exe" -f Makefile.Release Microsoft (R) 程序維護實用工具 12.00.21005.1 版 版權所有 (C) Microsoft Corporation。 保留所有權利。 cl -c -nologo -Zc:wchar_t -O2 -MD -W3 -w34100 -w34189 -w44996 -GR -EHsc -DUNICODE -DWIN32 -DQT_NO_DEBUG -DQT_PLUGIN -DQT_CORE_LIB -DNDEBUG -I. -I. -IC:Pythonpython3.6.1include -I..qpyQtCore -ID:QtQt5.5.0_x865.5msvc2013include -ID:QtQt5.5.0_x865.5msvc2013includeQtCore -Irelease -ID:QtQt5.5.0_x865.5msvc2013mkspecswin32-msvc2010 -Forelease @C:UsersArthurAppDataLocalTempnmFA8E.tmp qpycore_post_init.cpp sipQtCorecmodule.cpp sipQtCoreQAbstractAnimation.cpp sipQtCoreQAbstractEventDispatcher.cpp sipQtCoreQAbstractEventDispatcherTimerInfo.cpp sipQtCoreQAbstractItemModel.cpp sipQtCoreQAbstractListModel.cpp sipQtCoreQAbstractNativeEventFilter.cpp sipQtCoreQAbstractProxyModel.cpp sipQtCoreQAbstractState.cpp sipQtCoreQAbstractTableModel.cpp sipQtCoreQAbstractTransition.cpp sipQtCoreQAnimationGroup.cpp sipQtCoreQBasicTimer.cpp sipQtCoreQBitArray.cpp sipQtCoreQBuffer.cpp sipQtCoreQByteArray.cpp sipQtCoreQByteArrayBase64Options.cpp sipQtCoreQByteArrayMatcher.cpp sipQtCoreQChar.cpp 正在生成代碼... 正在編譯... sipQtCoreQChildEvent.cpp sipQtCoreQCollator.cpp sipQtCoreQCollatorSortKey.cpp sipQtCoreQCommandLineOption.cpp sipQtCoreQCommandLineParser.cpp sipQtCoreQCoreApplication.cpp sipQtCoreQCryptographicHash.cpp sipQtCoreQDataStream.cpp sipQtCoreQDate.cpp sipQtCoreQDateTime.cpp sipQtCoreQDir.cpp sipQtCoreQDirFilters.cpp sipQtCoreQDirIterator.cpp sipQtCoreQDirIteratorIteratorFlags.cpp sipQtCoreQDirSortFlags.cpp sipQtCoreQDynamicPropertyChangeEvent.cpp sipQtCoreQEasingCurve.cpp sipQtCoreQElapsedTimer.cpp sipQtCoreQEvent.cpp sipQtCoreQEventLoop.cpp 正在生成代碼... 正在編譯... sipQtCoreQEventLoopLocker.cpp sipQtCoreQEventLoopProcessEventsFlags.cpp sipQtCoreQEventTransition.cpp sipQtCoreQFile.cpp sipQtCoreQFileDevice.cpp sipQtCoreQFileDeviceFileHandleFlags.cpp sipQtCoreQFileDevicePermissions.cpp sipQtCoreQFileInfo.cpp sipQtCoreQFileSelector.cpp sipQtCoreQFileSystemWatcher.cpp sipQtCoreQFinalState.cpp sipQtCoreQGenericArgument.cpp sipQtCoreQGenericReturnArgument.cpp sipQtCoreQHash0100QString0100QVariant.cpp sipQtCoreQHash18000100QByteArray.cpp sipQtCoreQHistoryState.cpp sipQtCoreQIdentityProxyModel.cpp sipQtCoreqintptr.cpp sipQtCoreQIODevice.cpp sipQtCoreQIODeviceOpenMode.cpp 正在生成代碼... 正在編譯... sipQtCoreQItemSelection.cpp sipQtCoreQItemSelectionModel.cpp sipQtCoreQItemSelectionModelSelectionFlags.cpp sipQtCoreQItemSelectionRange.cpp sipQtCoreQJsonArray.cpp sipQtCoreQJsonDocument.cpp sipQtCoreQJsonObject.cpp sipQtCoreQJsonParseError.cpp sipQtCoreQJsonValue.cpp sipQtCoreQLibrary.cpp sipQtCoreQLibraryInfo.cpp sipQtCoreQLibraryLoadHints.cpp sipQtCoreQLine.cpp sipQtCoreQLineF.cpp sipQtCoreQList0100QAbstractEventDispatcherTimerInfo.cpp sipQtCoreQList0100QByteArray.cpp sipQtCoreQList0100QCommandLineOption.cpp sipQtCoreQList0100QFileInfo.cpp sipQtCoreQList0100QLocale.cpp sipQtCoreQList0100QMimeType.cpp 正在生成代碼... 正在編譯... sipQtCoreQList0100QModelIndex.cpp sipQtCoreQList0100QPersistentModelIndex.cpp sipQtCoreQList0100QStorageInfo.cpp sipQtCoreQList0100QtDayOfWeek.cpp sipQtCoreQList0100QUrl.cpp sipQtCoreQList0100QVariant.cpp sipQtCoreQList0101QAbstractAnimation.cpp sipQtCoreQList0101QAbstractState.cpp sipQtCoreQList0101QAbstractTransition.cpp sipQtCoreQList0101QObject.cpp sipQtCoreQList0600QPair0100QString0100QString.cpp sipQtCoreQList0600QPair18001800.cpp sipQtCoreQList1800.cpp sipQtCoreQList2400.cpp sipQtCoreQLocale.cpp sipQtCoreQLocaleNumberOptions.cpp sipQtCoreQLockFile.cpp sipQtCoreQMap0100QString0100QVariant.cpp sipQtCoreQMap18000100QVariant.cpp sipQtCoreQMargins.cpp 正在生成代碼... 正在編譯... sipQtCoreQMarginsF.cpp sipQtCoreQMessageAuthenticationCode.cpp sipQtCoreQMessageLogContext.cpp sipQtCoreQMessageLogger.cpp sipQtCoreQMetaClassInfo.cpp sipQtCoreQMetaEnum.cpp sipQtCoreQMetaMethod.cpp sipQtCoreQMetaObject.cpp sipQtCoreQMetaProperty.cpp sipQtCoreQMetaType.cpp sipQtCoreQMetaTypeTypeFlags.cpp sipQtCoreQMimeData.cpp sipQtCoreQMimeDatabase.cpp sipQtCoreQMimeType.cpp sipQtCoreQModelIndex.cpp sipQtCoreQMutex.cpp sipQtCoreQMutexLocker.cpp sipQtCoreQObject.cpp sipQtCoreQObjectCleanupHandler.cpp sipQtCoreQPair18001800.cpp 正在生成代碼... 正在編譯... sipQtCoreQParallelAnimationGroup.cpp sipQtCoreQPauseAnimation.cpp sipQtCoreQPersistentModelIndex.cpp sipQtCoreQPluginLoader.cpp sipQtCoreQPoint.cpp sipQtCoreQPointF.cpp sipQtCoreQProcess.cpp sipQtCoreQProcessEnvironment.cpp sipQtCoreQPropertyAnimation.cpp sipQtCoreQReadLocker.cpp sipQtCoreQReadWriteLock.cpp sipQtCoreQRect.cpp sipQtCoreQRectF.cpp sipQtCoreQRegExp.cpp sipQtCoreQRegularExpression.cpp sipQtCoreQRegularExpressionMatch.cpp sipQtCoreQRegularExpressionMatchIterator.cpp sipQtCoreQRegularExpressionMatchOptions.cpp sipQtCoreQRegularExpressionPatternOptions.cpp sipQtCoreQResource.cpp 正在生成代碼... 正在編譯... sipQtCoreQRunnable.cpp sipQtCoreQSaveFile.cpp sipQtCoreQSemaphore.cpp sipQtCoreQSequentialAnimationGroup.cpp sipQtCoreQSet0101QAbstractState.cpp sipQtCoreQSettings.cpp sipQtCoreQSharedMemory.cpp sipQtCoreQSignalBlocker.cpp sipQtCoreQSignalMapper.cpp sipQtCoreQSignalTransition.cpp sipQtCoreQSize.cpp sipQtCoreQSizeF.cpp sipQtCoreQSocketNotifier.cpp sipQtCoreQSortFilterProxyModel.cpp sipQtCoreQStandardPaths.cpp sipQtCoreQStandardPathsLocateOptions.cpp sipQtCoreQState.cpp sipQtCoreQStateMachine.cpp sipQtCoreQStateMachineSignalEvent.cpp sipQtCoreQStateMachineWrappedEvent.cpp 正在生成代碼... 正在編譯... sipQtCoreQStorageInfo.cpp sipQtCoreQString.cpp sipQtCoreQStringList.cpp sipQtCoreQStringListModel.cpp sipQtCoreQStringRef.cpp sipQtCoreQSysInfo.cpp sipQtCoreQSystemSemaphore.cpp sipQtCoreQt.cpp sipQtCoreQtAlignment.cpp sipQtCoreQtApplicationStates.cpp sipQtCoreQtDockWidgetAreas.cpp sipQtCoreQtDropActions.cpp sipQtCoreQtEdges.cpp sipQtCoreQTemporaryDir.cpp sipQtCoreQTemporaryFile.cpp sipQtCoreQTextBoundaryFinder.cpp sipQtCoreQTextBoundaryFinderBoundaryReasons.cpp sipQtCoreQTextCodec.cpp sipQtCoreQTextCodecConversionFlags.cpp sipQtCoreQTextCodecConverterState.cpp 正在生成代碼... 正在編譯... sipQtCoreQTextDecoder.cpp sipQtCoreQTextEncoder.cpp sipQtCoreQTextStream.cpp sipQtCoreQTextStreamManipulator.cpp sipQtCoreQTextStreamNumberFlags.cpp sipQtCoreQtFindChildOptions.cpp sipQtCoreQtGestureFlags.cpp sipQtCoreQThread.cpp sipQtCoreQThreadPool.cpp sipQtCoreQtImageConversionFlags.cpp sipQtCoreQTime.cpp sipQtCoreQTimeLine.cpp sipQtCoreQTimer.cpp sipQtCoreQTimerEvent.cpp sipQtCoreQTimeZone.cpp sipQtCoreQTimeZoneOffsetData.cpp sipQtCoreQtInputMethodHints.cpp sipQtCoreQtInputMethodQueries.cpp sipQtCoreQtItemFlags.cpp sipQtCoreQtKeyboardModifiers.cpp 正在生成代碼... 正在編譯... sipQtCoreQtMatchFlags.cpp sipQtCoreQtMouseButtons.cpp sipQtCoreQtMouseEventFlags.cpp sipQtCoreQtOrientations.cpp sipQtCoreQTranslator.cpp sipQtCoreQtScreenOrientations.cpp sipQtCoreQtTextInteractionFlags.cpp sipQtCoreQtToolBarAreas.cpp sipQtCoreQtTouchPointStates.cpp sipQtCoreQtWindowFlags.cpp sipQtCoreQtWindowStates.cpp sipQtCorequintptr.cpp sipQtCoreQUrl.cpp sipQtCoreQUrlComponentFormattingOptions.cpp sipQtCoreQUrlFormattingOptions.cpp sipQtCoreQUrlQuery.cpp sipQtCoreQUrlUserInputResolutionOptions.cpp sipQtCoreQUuid.cpp sipQtCoreQVariant.cpp sipQtCoreQVariantAnimation.cpp 正在生成代碼... 正在編譯... sipQtCoreQVector0100QPointF.cpp sipQtCoreQVector0100QTimeZoneOffsetData.cpp sipQtCoreQVector0100QXmlStreamEntityDeclaration.cpp sipQtCoreQVector0100QXmlStreamNamespaceDeclaration.cpp sipQtCoreQVector0100QXmlStreamNotationDeclaration.cpp sipQtCoreQVector0600QPair24000100QVariant.cpp sipQtCoreQVector1800.cpp sipQtCoreQWaitCondition.cpp sipQtCoreQWinEventNotifier.cpp sipQtCoreQWriteLocker.cpp sipQtCoreQXmlStreamAttribute.cpp sipQtCoreQXmlStreamAttributes.cpp sipQtCoreQXmlStreamEntityDeclaration.cpp sipQtCoreQXmlStreamEntityResolver.cpp sipQtCoreQXmlStreamNamespaceDeclaration.cpp sipQtCoreQXmlStreamNotationDeclaration.cpp sipQtCoreQXmlStreamReader.cpp sipQtCoreQXmlStreamWriter.cpp 正在生成代碼... cl -c -nologo -Zc:wchar_t -O2 -MD -W3 -w34100 -w34189 -w44996 -GR -EHsc -DUNICODE -DWIN32 -DQT_NO_DEBUG -DQT_PLUGIN -DQT_CORE_LIB -DNDEBUG -I. -I. -IC:Pythonpython3.6.1include -I..qpyQtCore -ID:QtQt5.5.0_x865.5msvc2013include -ID:QtQt5.5.0_x865.5msvc2013includeQtCore -Irelease -ID:QtQt5.5.0_x865.5msvc2013mkspecswin32-msvc2010 -Forelease @C:UsersArthurAppDataLocalTempnm2C0B.tmp qpycore_chimera.cpp ..qpyQtCoreqpycore_chimera.cpp(503) : error C2065: 「pyqt5ClassTypeDef」: 未聲明的標識符 ..qpyQtCoreqpycore_chimera.cpp(503) : error C2059: 語法錯誤:「)」 qpycore_chimera_signature.cpp qpycore_chimera_storage.cpp qpycore_classinfo.cpp qpycore_decorators.cpp qpycore_enums_flags.cpp qpycore_init.cpp qpycore_misc.cpp qpycore_public_api.cpp qpycore_pyqtboundsignal.cpp qpycore_pyqtconfigure.cpp qpycore_pyqtmethodproxy.cpp qpycore_pyqtproperty.cpp qpycore_pyqtpyobject.cpp qpycore_pyqtsignal.cpp ..qpyQtCoreqpycore_pyqtsignal.cpp(669) : error C2065: 「pyqt5ClassTypeDef」: 未聲明的標識符 ..qpyQtCoreqpycore_pyqtsignal.cpp(669) : error C2065: 「ctd」: 未聲明的標識符 ..qpyQtCoreqpycore_pyqtsignal.cpp(669) : error C2059: 語法錯誤:「)」 ..qpyQtCoreqpycore_pyqtsignal.cpp(670) : error C2065: 「ctd」: 未聲明的標識符 ..qpyQtCoreqpycore_pyqtsignal.cpp(670) : error C2227: 「->qt_signals」的左邊必須指向類/結構/聯合/泛型類型 類型是「unknown-type」 qpycore_pyqtslot.cpp qpycore_pyqtslotproxy.cpp qpycore_qjsonvalue.cpp qpycore_qmessagelogger.cpp qpycore_qmetaobject.cpp 正在生成代碼... 正在編譯... qpycore_qmetaobject_helpers.cpp qpycore_qobject_getattr.cpp qpycore_qobject_helpers.cpp ..qpyQtCoreqpycore_qobject_helpers.cpp(56) : error C2065: 「pyqt5ClassTypeDef」: 未聲明的標識符 ..qpyQtCoreqpycore_qobject_helpers.cpp(56) : error C2059: 語法錯誤:「)」 ..qpyQtCoreqpycore_qobject_helpers.cpp(56) : error C2143: 語法錯誤 : 缺少「(」(在「)」的前面) ..qpyQtCoreqpycore_qobject_helpers.cpp(241) : error C2039: 「type」: 不是「_sipWrapperType」的成員 C:Pythonpython3.6.1includesip.h(508) : 參見「_sipWrapperType」的聲明 ..qpyQtCoreqpycore_qobject_helpers.cpp(257) : error C2065: 「pyqt5ClassTypeDef」: 未聲明的標識符 ..qpyQtCoreqpycore_qobject_helpers.cpp(257) : error C2059: 語法錯誤:「)」 ..qpyQtCoreqpycore_qobject_helpers.cpp(258) : error C2143: 語法錯誤 : 缺少「;」(在「{」的前面) ..qpyQtCoreqpycore_qobject_helpers.cpp(285) : error C2065: 「pyqt5ClassTypeDef」: 未聲明的標識符 ..qpyQtCoreqpycore_qobject_helpers.cpp(285) : error C2065: 「pyqt_ctd」: 未聲明的標識符 ..qpyQtCoreqpycore_qobject_helpers.cpp(285) : error C2059: 語法錯誤:「)」 ..qpyQtCoreqpycore_qobject_helpers.cpp(287) : error C2065: 「pyqt_ctd」: 未聲明的標識符 ..qpyQtCoreqpycore_qobject_helpers.cpp(299) : error C2065: 「pyqt_ctd」: 未聲明的標識符 ..qpyQtCoreqpycore_qobject_helpers.cpp(299) : error C2227: 「->static_metaobject」的左邊必須指向類/結構/聯合/泛型類型 類型是「unknown-type」 qpycore_qstring.cpp qpycore_qvariant.cpp qpycore_qvariant_value.cpp qpycore_types.cpp ..qpyQtCoreqpycore_types.cpp(160) : error C2065: 「pyqt5ClassTypeDef」: 未聲明的標識符 ..qpyQtCoreqpycore_types.cpp(160) : error C2065: 「pyqt_td」: 未聲明的標識符 ..qpyQtCoreqpycore_types.cpp(160) : error C2059: 語法錯誤:「)」 ..qpyQtCoreqpycore_types.cpp(162) : error C2065: 「pyqt_td」: 未聲明的標識符 ..qpyQtCoreqpycore_types.cpp(166) : error C2065: 「pyqt_td」: 未聲明的標識符 ..qpyQtCoreqpycore_types.cpp(166) : error C2227: 「->static_metaobject」的左邊必須指向類/結構/聯合/泛型類型 類型是「unknown-type」 ..qpyQtCoreqpycore_types.cpp(583) : error C2065: 「pyqt5ClassTypeDef」: 未聲明的標識符 ..qpyQtCoreqpycore_types.cpp(583) : error C2059: 語法錯誤:「)」 ..qpyQtCoreqpycore_types.cpp(583) : error C2143: 語法錯誤 : 缺少「(」(在「)」的前面) 正在生成代碼... NMAKE : fatal error U1077: 「"C:Program Files (x86)Microsoft Visual Studio 12.0VCBINcl.EXE"」: 返回代碼「0x2」 Stop. NMAKE : fatal error U1077: 「"C:Program Files (x86)Microsoft Visual Studio 12.0VCBINnmake.exe"」: 返回代碼「0x2」 Stop. NMAKE : fatal error U1077: 「cd」: 返回代碼「0x2」 Stop. >
錯誤4.2: 要禁掉部分組件
第一次嘗試 PyQt-gpl-5.5
,我在nmake
這個步驟,編譯QtNfc
報錯,我估摸着是 QT5.5.0
不含有這個模塊,索性把 QtPositioning
, QtNfc
, QtBluetooth
, QtOpenGL
都禁掉了。我估計這些原來的 QT5.5.0
都沒有。
> cd c:PyQt-gpl-5.5 > python configure.py --disable=QtPositioning --disable=QtNfc --disable=QtBluetooth --disable=QtOpenGL > nmake
這下 nmake
算是成功了吧。好心塞

另外,附上PyQT5.10.1
中可以禁掉的模塊
'QtCore', 'QtAndroidExtras', 'QtDBus', 'QtGui', 'QtNetwork', 'QtNetworkAuth', 'QtSensors', 'QtSerialPort', 'QtMultimedia', 'QtQml', 'QtWebKit', 'QtWidgets', 'QtXml', 'QtXmlPatterns', 'QtAxContainer', 'QtDesigner', 'QtHelp', 'QtMultimediaWidgets', 'QtOpenGL', 'QtPrintSupport', 'QtQuick', 'QtSql', 'QtSvg', 'QtTest', 'QtWebKitWidgets', 'QtBluetooth', 'QtMacExtras', 'QtPositioning', 'QtWinExtras', 'QtX11Extras', 'QtQuickWidgets', 'QtWebSockets', 'Enginio', 'QtWebChannel', 'QtWebEngineCore', 'QtWebEngineWidgets', 'QtWebEngine', 'QtLocation', 'QtNfc'
step5. nmake install
終於成功了

測試
完美!

小結
花了整整一天的事情,在搞這個環境,要說收穫多,覺得有點窩火,要說少,也有點違心。
其實違背了初衷:
- 原來計劃:
VS2013 + Python3.6.1 + QT5.5.0 + PyQT5.5.0
- 現實情況:
VS2013 + Python3.6.1 + QT5.5.0 + PyQT5.10.1
乾貨
- 運用
nmake
前,先運行C:Program Files (x86)Microsoft Visual Studio 12.0VCbinvcvars32.bat
配置編譯環境 python configure.py
時,要學會用--disable=[組件]
來禁用部分模塊python configure.py
時,要學會用--verbose > [錯誤記錄.log]
來記錄configure
時的一些錯誤