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 --version
可以得到Python的版本号,例如:
- C:\>python --version
- Python 3.8.1
目前Python的版本已经更新到3.10.7。
在命令窗口输入:
- pip install pyqt5
-
- pip install pyqt5_tools
工具会自动替你安装好所有的工具包(包括依赖包)。
也可以从Pypi库(如国内的:https://pypi.tuna.tsinghua.edu.cn/simple、http://mirrors.aliyun.com/pypi/simple、http://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离线安装,安装顺序同上。
一切顺利的话,下一步按照网上介绍配置使用就行了。
方法一:安装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包会出错。
进入解压文件所在目录,在命令窗口依次安装:
- pip install pyqt5_sip
-
- pip install pyqt5_qt5
-
- pip install ./PyQt5-5.15.4-py3-none-win_amd64.whl
-
- pip install qt5_applications==5.15.2.2.2
-
- pip install click==7.1.2
-
- pip install qt5_tools==5.15.2.1.2
-
- pip install python_dotenv==0.21.0
-
- pip install ./pyqt5_plugins-5.15.4.2.2-py3-none-win_amd64.whl
-
- pip install pyqt5_tools==5.15.4.3.2
一切顺利的话就会安装成功,如果离线安装的话,除了上述两个特殊包外,也是去pypi库里去下载相关版本的包(与上述第(二)种情况相同的包),这里不再重复了。
如果是在线安装,按照我的方法一般不会出现问题,高版本的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.
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.
name:
Comment content: (supports up to 255 characters)
Copyright © 2018-2021 python black hole network All Rights Reserved All rights reserved, and all rights reserved.京ICP备18063182号-7
For complaints and reports, and advertising cooperation, please contact vgs_info@163.com or QQ3083709327
Disclaimer: All articles on the website are uploaded by users and are only for readers' learning and communication use, and commercial use is prohibited. If the article involves pornography, reactionary, infringement and other illegal information, please report it to us and we will delete it immediately after verification!