News from this site

 Rental advertising space, please contact the webmaster if you need cooperation


+focus
focused

classification  

no classification

tag  

no tag

date  

2024-11(6)

在不同版本Python中安装PyQT5及PyQT5-Tools

posted on 2023-05-03 20:46     read(585)     comment(0)     like(22)     collect(2)


QT is a collection of cross-platform C++ libraries that implement high-level APIs to access many aspects of desktop and mobile systems, including location and location services, multimedia, NFC and Bluetooth connectivity, Chromium-based web browsers, and traditional UI development.

PyQT5 is a complete set of Python bindings for QT v5. It implements more than 35 extension modules and enables Python to be used as an alternative application development language to C++ on all supported platforms, including iOS and Android. PyQT5 can also be embedded in C++ based applications to allow enhanced functionality for these applications.

PyQT5 is easy to use, powerful, cross-platform support, high performance, complete documentation (in addition to its own documentation, almost universal QT documentation), high stability, open source and free, etc. In particular, it also provides Designer tools, which can be accessed through The graphical drag-and-drop method simplifies the window interface design, and the generated UI interface file can be converted into a Python program through the provided UIC tool!

Therefore, PyQT5 is very popular in Python window programming.

Installing PyQT5 is actually very simple, enter in the command window:

pip install pyqt5

It can be installed automatically. The key is to install PyQT5-Tools. When the Python version is higher than 3.9, an error will occur and the installation will not be successful!
If you don't want to use the PyQT5 Designer tool, it doesn't matter, just use it directly. If you still want to use the Designer, you have to find a way to install PyQT5-Tools.
After some Internet search and verification, I have sorted out the specific installation method:

(一)首先,确定自己的Python版本:

在命令窗口输入:

Python --version

可以得到Python的版本号,例如:

  1. C:\>python --version
  2. Python 3.8.1

目前Python的版本已经更新到3.10.7。

(二)如果你安装的Python版本低于3.9.x,那么恭喜!安装PyQT5-Tools想当简单:

在命令窗口输入:

  1. pip install pyqt5
  2. pip install pyqt5_tools

工具会自动替你安装好所有的工具包(包括依赖包)。
也可以从Pypi库(如国内的:https://pypi.tuna.tsinghua.edu.cn/simplehttp://mirrors.aliyun.com/pypi/simplehttp://pypi.douban.com/simple等)下载以下包:

==========PyQT5==========
PyQT5-sip-12.11.0
PyQT5-QT5-5.15.2
PyQt5-5.15.4  (注:若要安装PyQT5-Tools,目前只能这个版本)

==========PyQT5-Tools==========
qt5-applications-5.15.2.2.2
click-7.1.2  (注:若要安装qt5-tools,目前只能这个版本)
qt5-tools-5.15.2.1.2
python-dotenv-0.21.0
PyQT5-plugins-5.15.4.2.2
PyQT5-tools-5.15.4.3.2

用pip离线安装,安装顺序同上。
一切顺利的话,下一步按照网上介绍配置使用就行了。

(三)如果你安装的Python版本高于3.9.x,如:3.10.7,那么想安装PyQT5-Tools有两种方法:

方法一:安装PyQT5Designer(毕竟我们安装PyQT5-Tools的目的是使用Designer):
在命令窗口输入:

pip install pyqt5designer

离线安装,也是到pypi库中下载PyQT5Designer相关包安装就行了,这里就不赘述了。

方法二:
下载以下离线包:
PyQt5-5.15.4-py3-none-win_amd64.whl
pyqt5_plugins-5.15.4.2.2-py3-none-win_amd64.whl
可以在这里下载:https://github.com/altendky/pyqt-tools/files/8184444/PyQt5-tools-renamed-packages.zip
下载完后,解压缩到某个目录,得到这两个包。这两个包其实就是在Python高版本中安装低版本的PyQT5的改造包,直接在线安装低版本的PyQT5包会出错。
进入解压文件所在目录,在命令窗口依次安装:

  1. pip install pyqt5_sip
  2. pip install pyqt5_qt5
  3. pip install ./PyQt5-5.15.4-py3-none-win_amd64.whl
  4. pip install qt5_applications==5.15.2.2.2
  5. pip install click==7.1.2
  6. pip install qt5_tools==5.15.2.1.2
  7. pip install python_dotenv==0.21.0
  8. pip install ./pyqt5_plugins-5.15.4.2.2-py3-none-win_amd64.whl
  9. pip install pyqt5_tools==5.15.4.3.2

一切顺利的话就会安装成功,如果离线安装的话,除了上述两个特殊包外,也是去pypi库里去下载相关版本的包(与上述第(二)种情况相同的包),这里不再重复了。

(四)经过上述方法安装,你就可以使用PyQt5及PyQT5-Tools了,可以直接在命令行使用,需要配置PATH环境变量。强烈推荐在Pycharm中使用,这方面配置方法网上介绍很多,自行上网学习就行。

(五)可能出现的问题:

如果是在线安装,按照我的方法一般不会出现问题,高版本的Python一定要下载这两个改造包安装;

If it is an offline installation, the same version may have different package files when downloading, and only the correct package can be installed. You need to download and try it yourself. Generally, files with "none" are fine.



Category of website: technical article > Blog

Author:Poison

link:http://www.pythonblackhole.com/blog/article/250/7310b90786927acb6ddc/

source:python black hole net

Please indicate the source for any form of reprinting. If any infringement is discovered, it will be held legally responsible.

22 0
collect article
collected

Comment content: (supports up to 255 characters)