PyQt5 5.8.2 在 Windows 10 上从源代码构建

Posted

技术标签:

【中文标题】PyQt5 5.8.2 在 Windows 10 上从源代码构建【英文标题】:PyQt5 5.8.2 build from source on Windows 10 【发布时间】:2017-04-30 05:13:41 【问题描述】:

我使用 Python 3.6 和 Qt 5.8 的 qmake 和 VS2017 的 nmake 来尝试从源代码构建 PyQt5。

但是,我在第一步的过程中遇到了如下错误

python configure.py --verbose

C:\Qt\5.8\msvc2015_64\include\QtCore/qalgorithms.h(593): error C3615: constexpr function 'QAlgorithmsPrivate::qt_builtin_ctz' cannot result in a constant expression
C:\Qt\5.8\msvc2015_64\include\QtCore/qalgorithms.h(595): note: failure was caused by an uninitialized variable declaration
C:\Qt\5.8\msvc2015_64\include\QtCore/qalgorithms.h(595): note: see usage of 'result'
C:\Qt\5.8\msvc2015_64\include\QtCore/qalgorithms.h(596): note: failure was caused by an illegal statement or expression
C:\Qt\5.8\msvc2015_64\include\QtCore/qalgorithms.h(600): error C3615: constexpr function 'QAlgorithmsPrivate::qt_builtin_clz' cannot result in a constant expression
C:\Qt\5.8\msvc2015_64\include\QtCore/qalgorithms.h(602): note: failure was caused by an uninitialized variable declaration
C:\Qt\5.8\msvc2015_64\include\QtCore/qalgorithms.h(602): note: see usage of 'result'
C:\Qt\5.8\msvc2015_64\include\QtCore/qalgorithms.h(603): note: failure was caused by an illegal statement or expression
.
.
.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\bin\HostX64\x64\cl.EXE"' : return code '0x2'
Stop.
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\bin\HostX64\x64\nmake.exe"' : return code '0x2'
Stop.

注意:我稍后使用pip install PyQt5 成功安装了 PyQt5,它工作正常。但我只是无法弄清楚为什么会发生错误,我仍然想解决它以避免将来出现同样的问题。

【问题讨论】:

尝试在 PyQt 邮件列表中询问作者。 可能与this bug report有关。你真的需要用 VS2017 构建吗?由于您使用的是 Qt 的 VS2015 版本,因此您可能应该使用相同的版本构建 PyQt,以避免使用多个 MSVC 运行时。 【参考方案1】:

在user3419537 's suggestion 上,似乎通过 VS2015 构建和编译工作正常。

【讨论】:

以上是关于PyQt5 5.8.2 在 Windows 10 上从源代码构建的主要内容,如果未能解决你的问题,请参考以下文章

PyQt5中的QWebEngineView和QWidget

PyQt5 中的 QWebEngineView 和 QWidget

Windows 10 怎样安装 PyQt5?

Windows下安装PyQt5完整教程

如何在 Windows 10 上使用 python 3.7.0a2 安装 PyQt5

pyqt5 QTextEdit Windows 10 ASCII 符号