简体   繁体   English

如何在 Windows 上安装 PyQt5?

[英]How to install PyQt5 on Windows?

When I try installing the PyQt5 on Windows using the command当我尝试使用命令在 Windows 上安装 PyQt5

python configure.py

I get this error:我收到此错误:

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

I got the pyQt5 from PyQt5 Download .我从PyQt5 Download得到了 pyQt5。

How can I install PyQt5?如何安装 PyQt5?


Update:更新:

I installed Qt 5.0.2 for Windows 64-bit (VS 2012, 500 MB) from the Qt Download page and now I have this error:我从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.

And when I execute the command python configure.py --verbose :当我执行命令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.

I added C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin (contains nmake.exe ) to PATH and I got this error:我将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.

Mainly I use the following command under the cmd主要是我在cmd下使用如下命令

pip install pyqt5

And it works with no problem!它没有问题!

The easiest way to install PyQt is to just use the installer (Link in your answer, step #5).安装 PyQt 的最简单方法是使用安装程序(答案中的链接,步骤 #5)。 If you install python 3.3, the installer will add all of the PyQt5 extras to that python installation automatically.如果您安装 python 3.3,安装程序将自动将所有 PyQt5 附加功能添加到该 python 安装中。 You won't need to do any compiling (none of: nmake, nmake install, python configure).您不需要进行任何编译(没有:nmake、nmake install、python configure)。

All of the build options are available for if you need a custom install (for instance, using a different version of python, where there isn't an installer provided by riverbank computing).如果您需要自定义安装(例如,使用不同版本的 python,河岸计算没有提供安装程序),则所有构建选项都可用。

If you do need to compile your own version of PyQt5, the steps (as you have found) are here , but assume you have python and a compiler installed and in your path.如果您确实需要编译自己的 PyQt5 版本,步骤(如您所见)在此处,但假设您已安装 python 和编译器并在您的路径中。 The installed and in your path have been where you have been running into trouble it seems.安装并在您的路径中似乎是您遇到麻烦的地方。 I'd recommend using the installer version, but you need to install python 3.3 first.我建议使用安装程序版本,但您需要先安装python 3.3

First try this in your Windows cmd window:首先在您的 Windows cmd 窗口中尝试此操作:

pip3 install pyqt5

If that is successful, it will look something like this:如果成功,它将如下所示:

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

If that did not work, you might try this link from SourceForge.如果这不起作用,你可以试试 SourceForge 的这个链接。

PyQt5 .exe installers for Windows适用于 Windows 的 PyQt5 .exe 安装程序

How to find the installer that's right for you?如何找到适合您的安装程序?

First, determine what version of Python you have and whether you have 32-bit or 64-bit Python.首先,确定您拥有的 Python 版本以及您拥有 32 位还是 64 位 Python。 Next, open one of the directories.接下来,打开其中一个目录。 I'm on Python 3.5 64-bit so I'm looking for a .exe with those specs.我在 Python 3.5 64 位,所以我正在寻找具有这些规格的 .exe。 When you open a directory on SourceForge, you will see some directories with ONLY .zip or .tar.gz .当您在 SourceForge 上打开一个目录时,您会看到一些只有.zip.tar.gz的目录。 That's not what you're looking for.这不是你要找的。 A good indication of which directory you should click is given by the "Downloads/Week" column. “下载/周”列很好地指示了您应该单击哪个目录。 I'll open the PyQt-5.6 directory in my case.在我的例子中,我将打开PyQt-5.6目录。

Here we notice some .exe files:这里我们注意到一些 .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

I know these are Python 3.5 by Py3.5 in the file name.我知道这些是 Python 3.5 by Py3.5的文件名。 I am also looking for the 64-bit version so I'll download PyQt5-5.6-gpl-Py3.5-Qt5.6.0-x64-2.exe .我也在寻找 64 位版本,所以我会下载PyQt5-5.6-gpl-Py3.5-Qt5.6.0-x64-2.exe Final answer!最终答案!

Note: if you try to install a version that's not compatible with your system, a dialog box will appear immediately after running the .exe.注意:如果您尝试安装与您的系统不兼容的版本,运行 .exe 后会立即出现一个对话框。 That's an indication that you've chosen the wrong one.这表明你选错了。 I'm not trying to sound like a dbag... I did that several times!我不想让自己听起来像个 dbag……我这样做了好几次!

To test a successful install, in your Python interpreter, try to import:要测试成功安装,请在 Python 解释器中尝试导入:

from PyQt5 import QtCore, QtGui, QtWidgets

I found a partial solution...我找到了部分解决方案...

Steps to install pyQt5 (with VS 2012) on Windows:在 Windows 上安装 pyQt5(使用 VS 2012)的步骤:

1) Install the binary file Qt 5.0.2 for Windows 64-bit (VS 2012, 500 MB) from here . 1) 从这里安装二进制文件Qt 5.0.2 for Windows 64-bit (VS 2012, 500 MB)

2) Get sip-4.14.7 (development snapshot) from here . 2)从这里获取sip-4.14.7 (开发快照)。

3) Extract the file and open the Developer Command Prompt for VS2012 . 3) 解压文件并打开Developer Command Prompt for VS2012

4) Execute these commands (in sip folder): 4)执行这些命令(在 sip 文件夹中):

python configure.py
nmake
nmake install

5) Get the pyQt5 from here . 5) 从这里获取pyQt5

6) Extract the file and open the VS2012 x64 Native Tools Command Prompt . 6) 解压文件并打开VS2012 x64 Native Tools Command Prompt

7) Execute these commands: 7)执行这些命令:

python configure.py

UPDATE: When execute these commands below is not working:更新:当执行以下这些命令不起作用时:

nmake
nmake install

Solution: I will try use pyQt4 with Qt5... because pyQt5 is in development and doesn't have support/documentation yet.解决方案:我将尝试将 pyQt4 与 Qt5 一起使用......因为 pyQt5 正在开发中,还没有支持/文档​​。

One of the most (probably the most) easiest way to install site-packages like PyQt5 is installing one of the versions of Anaconda.安装像 PyQt5 这样的站点包的最(可能是最)简单的方法之一是安装 Anaconda 的一个版本。 You can just install many of site-packages by installing it.您可以通过安装它来安装许多站点包。 List of avaliable site-packages with Anaconda versions can be checked here .可以在此处查看具有 Anaconda 版本的可用站点包列表。

  1. Dowload Anaconda3 or Anaconda2下载 Anaconda3或 Anaconda2
  2. Install it.安装它。
  3. Add PyQt5's path inside Anaconda installation to your System Environment Variables.将 Anaconda 安装中 PyQt5 的路径添加到您的系统环境变量中。

For example:例如:

PATH: ....; C:\Anaconda3\Lib\site-packages\PyQt5; ...
  1. It is ready to use.它可以使用了。

I'm new to both Python and PyQt5.我是 Python 和 PyQt5 的新手。 I tried to use pip, but I was having problems with it using a Windows machine.我尝试使用 pip,但在使用 Windows 机器时遇到了问题。 If you have a version of Python 3.4 or above, pip is installed and ready to use like so:如果您有 Python 3.4 或更高版本,则 pip 已安装并可以使用,如下所示:

python -m pip install pyqt5 

That's of course assuming that the path for Python executable is in your PATH environment variable.这当然是假设 Python 可执行文件的路径在您的 PATH 环境变量中。 Otherwise include the full path to Python executable (you can type where python to the Command Window to find it) like:否则包括 Python 可执行文件的完整路径(您可以在命令行窗口中键入where python来查找它),例如:

C:\users\userName\AppData\Local\Programs\Python\Python34\python.exe -m pip install pyqt5

If you're using Windows 10, if you use如果您使用的是 Windows 10,如果您使用

    py -m pip install pyqt5

in the command prompt it should download fine.在命令提示符下,它应该可以正常下载。 Depending on either the version of Python or Windows sometimes python -m pip install pyqt5 isn't accepted, so you have to use py instead.根据 Python 或 Windows 的版本,有时不接受python -m pip install pyqt5 ,因此您必须改用 py。 pip is a good way to download a lot of stuff, so I'd recommend that. pip 是下载很多东西的好方法,所以我建议这样做。

cmd下的另一个命令是:

easy_install pyqt5

If you have python installed completely, it can save you the hassle.如果你已经完全安装了 python,它可以为你省去麻烦。 All you need to do is enter the following command in your respective shell:您需要做的就是在各自的 shell 中输入以下命令:

pip install pyqt5

And contrary to popular belief, AS LONG AS YOU HAVE PIP INSTALLED, you can do this on virtually any OS... Hope this helped!与普遍的看法相反,只要您安装了 PIP,您几乎可以在任何操作系统上执行此操作......希望这会有所帮助!

It can be installed with below simple command:可以使用以下简单命令安装它:

pip3 install pyqt5

Download whl from here http://mirrors.aliyun.com/pypi/simple/pyqt5/从这里下载 whl http://mirrors.aliyun.com/pypi/simple/pyqt5/

pip install PyQt5-5.15.4-cp36.cp37.cp38.cp39-none-win_amd64.whl

If error comes try this如果出现错误,试试这个

pip install --user PyQt5-5.15.4-cp36.cp37.cp38.cp39-none-win_amd64.whl

Done完毕

如果您使用的是 canopy,请使用包管理器安装 qt(和或 pyqt)

You can easily install it using Anaconda.您可以使用 Anaconda 轻松安装它。 At first install Anaconda or Miniconda on you system (download from here ) and then install the pyqt as follow:首先在您的系统上安装AnacondaMiniconda (从此处下载),然后按如下方式安装 pyqt:

conda install pyqt

It works for both version of python (2 and 3).它适用于两个版本的 python(2 和 3)。

To install the GPL version of PyQt5, run (see PyQt5 Project ):要安装 PyQt5 的 GPL 版本,请运行(请参阅PyQt5 项目):

pip3 install pyqt5

This will install the Python wheel for your platform and your version of Python (assuming both are supported ).这将为您的平台和您的 Python 版本安装Python 轮(假设两者都受支持)。

(The wheel will be automatically downloaded from the Python Package Index .) (轮子会自动从Python Package Index下载。)

The PyQt5 wheel includes the necessary parts of the LGPL version of Qt . PyQt5 轮包含 Qt 的 LGPL 版本的必要部分 There is no need to install Qt yourself .无需自己安装 Qt

(The required sip is packaged as a separate wheel and will be downloaded and installed automatically .) (所需的sip打包成单独的轮子,会自动下载安装。)


Note :注意

If you get an error message saying something as如果您收到一条错误消息,说明如下

No downloads could be found that satisfy the requirement

then you are probably using an unsupported version of Python.那么您可能正在使用不受支持的 Python 版本

If you are facing problem with pip3 install pyqt5 then try pip3 install pyqt5==5.12.0如果您pip3 install pyqt5的问题,请尝试pip3 install pyqt5==5.12.0
This solved the problem for me这为我解决了问题

最简单的方法,我认为下载Eric,解压到源,打开python目录,将安装脚本拖到python图标,而不是文件夹,按照提示

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

                                                                                                                                                                                       

I was having issue due to spyder and the versions were colliding so I tried this由于 spyder 和版本冲突,我遇到了问题,所以我尝试了这个

pip uninstall pyqt5

pip uninstall spyder

pip install spyder 

This installed all!这都安装好了!

在命令提示符下键入:

pip install pyqt5

i've the same issue, but i found out that my problem was linked to the environment variables, because the cmd could not find "pip" i edited the variables and run the command pip3 install pyqt5 and i managed to install pyqt5 without problem我有同样的问题,但我发现我的问题与环境变量有关,因为 cmd 找不到“pip” 我编辑了变量并运行命令pip3 install pyqt5并且我成功安装了 pyqt5 没有问题

Hope that could help希望能有所帮助

check this guide it is in italian but is easy 检查本指南它是意大利语,但很容易

You can try running the following:您可以尝试运行以下命令:

python3 -m pip install pyqt5 

and if you want to use pytqt5-tools with designer you can try with:如果您想将pytqt5-tools与设计师一起使用,您可以尝试:

python3 -m pip install pip install PySide2

Hello there you can get your answers from here: https://www.lfd.uci.edu/~gohlke/pythonlibs/您好,您可以从这里获得答案: https ://www.lfd.uci.edu/~gohlke/pythonlibs/

To find your module press ctrl + f then type pyqt5 then click anyone of the file which matches your system related to PyQt5 then after you download your module extract it to python >> lib >> site-packages.要找到您的模块,请按 ctrl + f 然后键入 pyqt5 然后单击与您的系统匹配的与 PyQt5 相关的任何文件,然后在下载模块后将其解压缩到 python >> lib >> site-packages。 then extract it there I m done with my Answer hope its helpfull然后在那里提取它我已经完成了我的答案希望它有帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM