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
  • 测试
  • 小结
    • 干货

先放资源

需要环境为:

  1. VS2013
  2. 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

这个cstddefC: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中配置环境啊,那个大佬会,跪求讲解】

下图所示,各种拖进来的libh文件,很无奈。

错误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

干货

  1. 运用 nmake前,先运行 C:Program Files (x86)Microsoft Visual Studio 12.0VCbinvcvars32.bat 配置编译环境
  2. python configure.py时,要学会用 --disable=[组件]来禁用部分模块
  3. python configure.py时,要学会用 --verbose > [错误记录.log]来记录configure时的一些错误