如何在Windows上安装PyQt5?

32
当我尝试在Windows上使用命令安装PyQt5时,需要执行以下步骤:
python configure.py

我得到了这个错误:
Error: Make sure you have a working Qt qmake on your PATH.
我从PyQt5下载获取了pyQt5。
我该如何安装PyQt5?

更新:

我从Qt下载页面下载并安装了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.
我将"C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin"(包含“nmake.exe”)添加到PATH中,但我遇到了以下错误:
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.

1
你安装了QT吗?pyQT应该需要QT。 - brentlance
1
我安装了QT,现在出现另一个错误:'nmake'不是内部命令. 如何解决? - Victor Lellis
1
我认为虽然您已将nmake.exe添加到了PATH中,但还需要设置其他环境变量(例如包含和库路径)。对我而言有效的方法是从Visual Studio命令提示符中运行所有命令。这将自动设置所有必要的环境变量。VS Cmd提示符应该与VS一起安装,并且应该在您的开始菜单中。我成功编译并安装了PyQT5,但当我运行任何示例时,都会出现错误,例如: from PyQt5.QtCore import QEventLoop, QTime SystemError: error return without exception set - actf
@actf pip3安装pyqt5 - tyasird
22个回答

1
如果您已经完全安装了Python,那么它可以为您省去很多麻烦。您只需要在相应的Shell中输入以下命令即可:
pip install pyqt5

与普遍观点相反,只要您已安装了PIP,几乎可以在任何操作系统上执行此操作......希望这有所帮助!


1
从这里http://mirrors.aliyun.com/pypi/simple/pyqt5/下载whl文件。
pip install PyQt5-5.15.4-cp36.cp37.cp38.cp39-none-win_amd64.whl

如果出现错误,请尝试这个。
pip install --user PyQt5-5.15.4-cp36.cp37.cp38.cp39-none-win_amd64.whl

完成


0
如果您正在使用Canopy,可以使用包管理器安装Qt(和/或PyQt)。

0

您可以使用Anaconda轻松安装它。首先在您的系统上安装AnacondaMiniconda(从这里下载),然后按照以下步骤安装pyqt:

conda install pyqt

它适用于Python的两个版本(2和3)。


0

我认为最简单的方法是下载Eric,解压缩后进入源代码文件夹,打开Python目录,将安装脚本拖到Python图标上而非文件夹中,然后按照提示进行操作。


0
你可以尝试运行以下代码:
python3 -m pip install pyqt5 

如果你想在设计师中使用pyqt5-tools,可以尝试以下方法:

python3 -m pip install pip install PySide2

0
C:\Users\Digiline>python3 -m pip install pyqt5                                                                                                                          

Collecting pyqt5                                                                                                                                                          Downloading PyQt5-5.15.4-cp36.cp37.cp38.cp39-none-win_amd64.whl (6.8 MB)                                                                                                   |████████████████████████████████| 6.8 MB 3.3 MB/s                                                                                                                 Collecting PyQt5-sip<13,>=12.8                                                                                                                                            Downloading PyQt5_sip-12.8.1-cp39-cp39-win_amd64.whl (63 kB)                                                                                                               |████████████████████████████████| 63 kB 71 kB/s                                                                                                                   Collecting PyQt5-Qt5>=5.15                                                                                                                                                Downloading PyQt5_Qt5-5.15.2-py3-none-win_amd64.whl (50.1 MB)                                                                                                              |████████████████████████████████| 50.1 MB 16 kB/s                                                                                                                 Installing collected packages: PyQt5-sip, PyQt5-Qt5, pyqt5 
                                                                                                               
WARNING: The scripts pylupdate5.exe, pyrcc5.exe and pyuic5.exe are installed in 'C:\Users\Digiline\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\Scripts' which is not on PATH.                                                                                                   Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.                                                     Successfully installed PyQt5-Qt5-5.15.2 PyQt5-sip-12.8.1 pyqt5-5.15.4

                                                                                                                                                                                       

0

我遇到了由于Spyder引起的问题,版本冲突,所以我尝试了这个方法。

pip uninstall pyqt5

pip uninstall spyder

pip install spyder 

这个已经安装好了!


0
在命令提示符中键入:
pip install pyqt5

这是一个重复的答案。 - shortorian

0
我遇到了同样的问题,但是我发现我的问题与环境变量有关,因为cmd找不到“pip” 我编辑了变量并运行了命令 pip3 install pyqt5 我成功地安装了pyqt5,没有任何问题。
希望这能帮助到你。 看看这个指南它是意大利语的,但很容易理解。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接