如何在Windows上安装PyQt5?

2024-05-19 15:21:31 发布

您现在位置:Python中文网/ 问答频道 /正文

当我尝试使用命令在Windows上安装PyQt5时

python configure.py

我得到这个错误:

Error: Make sure you have a working Qt qmake on your PATH.

我从PyQt5 Download拿到了pyQt5。

如何安装PyQt5?


更新:

我从Qt Download page安装了Qt 5.0.2 for Windows 64-bit (VS 2012, 500 MB),现在出现以下错误:

Querying qmake about your Qt installation...
Determining the details of your Qt installation...
Error: Failed to determine the detail of your Qt installation. Try again using
the --verbose flag to see more detail about the problem.

当我执行命令python configure.py --verbose时:

Querying qmake about your Qt installation...
Determining the details of your Qt installation...
C:\Qt\Qt5.0.2\5.0.2\msvc2012_64\bin\qmake.exe -spec win32-msvc2008 -o qtdetail.m
k qtdetail.pro
nmake -f qtdetail.mk release
'nmake' não é reconhecido como um comando interno
ou externo, um programa operável ou um arquivo em lotes.
Error: Failed to determine the detail of your Qt installation. Try again using
the --verbose flag to see more detail about the problem.

我向PATH添加了C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin(包含nmake.exe),得到了以下错误:

Querying qmake about your Qt installation...
Determining the details of your Qt installation...
C:\Qt\Qt5.0.2\5.0.2\msvc2012_64\bin\qmake.exe -spec win32-msvc2008 -o qtdetail.mk qtdetail.pro
nmake -f qtdetail.mk release


Microsoft (R) Program Maintenance Utility Version 11.00.50727.1

Copyright (C) Microsoft Corporation.  All rights reserved.


  "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\nmake.exe" -f qtdetail.mk.Release


Microsoft (R) Program Maintenance Utility Version 11.00.50727.1

Copyright (C) Microsoft Corporation.  All rights reserved.

  cl -c -nologo -Zm200 -Zc:wchar_t -O2 -MD -GR -W3 -w34100 -w34189 -EHsc -DUNICODE -DWIN32 -DQT_NO_DEBUG -DQT_CORE_LIB -I"..\..\..\..\..\..\..\Qt\Qt5.0.2\5.0.2\msvc2012_64\include" -I"..\..\..\..\..\..\..\Qt\Qt5.0.2\5.0.2\msvc2012_64\include\QtCore" -I"release" -I"..\..\..\..\..\..\..\Qt\Qt5.0.2\5.0.2\msvc2012_64\mkspecs\win32-msvc2008" -Forelease\ @C:\Users\Victor\AppData\Local\Temp\nm68EA.tmp

NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\cl.EXE"' : return code '0xc0000135'

Stop.

NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\nmake.exe"' : return code '0x2'

Stop.

Tags: ofthetoyourbininstallationprogramqt
3条回答

我主要在cmd下使用以下命令

pip install pyqt5

而且没问题!

首先在Windows cmd窗口中尝试此操作:

pip3 install pyqt5

如果这是成功的,它将看起来像这样:

C:\Windows\System32>pip3 install pyqt5
Collecting pyqt5
  Downloading PyQt5-5.9-5.9.1-cp35.cp36.cp37-none-win_amd64.whl (77.2MB)
    100% |################################| 77.2MB 13kB/s
Collecting sip<4.20,>=4.19.3 (from pyqt5)
  Downloading sip-4.19.3-cp35-none-win_amd64.whl (49kB)
    100% |################################| 51kB 984kB/s
Installing collected packages: sip, pyqt5
Successfully installed pyqt5-5.9 sip-4.19.3

如果不起作用,您可以从SourceForge尝试此链接。

PyQt5 .exe installers for Windows

如何找到适合您的安装程序?

首先,确定您拥有的Python版本,以及您拥有的是32位还是64位Python。 接下来,打开其中一个目录。我使用的是Python3.564位,所以我正在寻找一个带有这些规范的.exe。打开SourceForge上的目录时,您将看到一些目录只有.zip.tar.gz。这不是你要找的。“Downloads/Week”列很好地指示了您应该单击哪个目录。 在本例中,我将打开PyQt-5.6目录。

这里我们注意到一些.exe文件:

PyQt-5.6
|_PyQt5-5.6-gpl-Py3.5-Qt5.6.0-x32-2.exe
|_PyQt5-5.6-gpl-Py3.5-Qt5.6.0-x64-2.exe
|_PyQt5_gpl-5.6.zip
|_PyQt5_gpl-5.6.tar.gz

我知道这些是Python 3.5文件名中的Py3.5。我也在寻找64位版本,所以我将下载PyQt5-5.6-gpl-Py3.5-Qt5.6.0-x64-2.exe。最后的答案!

注意:如果您试图安装与系统不兼容的版本,则在运行.exe后会立即出现一个对话框。这表明你选错了。我不想听起来像个dbag。。。我做了好几次!

要测试成功的安装,请在Python解释器中尝试导入:

from PyQt5 import QtCore, QtGui, QtWidgets

安装PyQt的最简单方法是使用安装程序(在您的答案中链接,步骤5)。如果安装Python3.3,安装程序将自动将所有PyQt5附加程序添加到该python安装中。您不需要进行任何编译(不需要:nmake、nmake install、python configure)。

如果您需要自定义安装(例如,使用不同版本的python,而riverbank computing没有提供安装程序),则可以使用所有的构建选项。

如果您确实需要编译自己版本的PyQt5,那么步骤(如您所发现的)是here,但是假设您已经安装了python和编译器,并且在您的路径中。安装的和在你的路径上的已经是你遇到麻烦的地方了。我建议您使用安装程序版本,但您需要首先安装python 3.3

相关问题 更多 >