Windows下安裝PyQt5
安裝Python
往期文章
安裝PyQt5
概述:pip 安裝PyQt5, PyQt5-tools
-
安裝PyQt5
python官方源下載較慢梯轻,因此使用阿里云的國內(nèi)鏡像源压固。C:\Users\admin>pip install PyQt5 -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com Looking in indexes: http://mirrors.aliyun.com/pypi/simple/ Collecting PyQt5 Downloading http://mirrors.aliyun.com/pypi/packages/9e/53/9476464c2a8db5252de96fd8ff39ec5db6ef09b8a08a7152546b7f142d90/PyQt5-5.15.4-cp36.cp37.cp38.cp39-none-win_amd64.whl (6.8 MB) |████████████████████████████████| 6.8 MB 3.2 MB/s Collecting PyQt5-Qt5>=5.15 Downloading http://mirrors.aliyun.com/pypi/packages/37/97/5d3b222b924fa2ed4c2488925155cd0b03fd5d09ee1cfcf7c553c11c9f66/PyQt5_Qt5-5.15.2-py3-none-win_amd64.whl (50.1 MB) |████████████████████████████████| 50.1 MB 547 kB/s Collecting PyQt5-sip<13,>=12.8 Downloading http://mirrors.aliyun.com/pypi/packages/4b/67/4d4f176ebd76673f0701fbb8a571f1b25d6f8b9b52c3e8905a375d87b925/PyQt5_sip-12.8.1-cp38-cp38-win_amd64.whl (63 kB) |████████████████████████████████| 63 kB 686 kB/s Installing collected packages: PyQt5-sip, PyQt5-Qt5, PyQt5 Successfully installed PyQt5-5.15.4 PyQt5-Qt5-5.15.2 PyQt5-sip-12.8.1
-
安裝Qt工具
C:\Users\admin>pip install PyQt5-tools -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com Looking in indexes: http://mirrors.aliyun.com/pypi/simple/ Collecting PyQt5-tools Downloading http://mirrors.aliyun.com/pypi/packages/da/a3/f791afe43c4bd6e1b2b1f7b4e53a84bc0d12e39a059a47d8d3bf59c8e265/pyqt5_tools-5.15.2.3.0.2-py3-none-any.whl (28 kB) Collecting click Downloading http://mirrors.aliyun.com/pypi/packages/d2/3d/fa76db83bf75c4f8d338c2fd15c8d33fdd7ad23a9b5e57eb6c5de26b430e/click-7.1.2-py2.py3-none-any.whl (82 kB) |████████████████████████████████| 82 kB 364 kB/s Collecting pyqt5==5.15.2 Downloading http://mirrors.aliyun.com/pypi/packages/aa/72/754c693db0e745b9fe47debc3ec52844461f090d5beff28489a0cde5ef82/PyQt5-5.15.2-5.15.2-cp35.cp36.cp37.cp38.cp39-none-win_amd64.whl (56.9 MB) |████████████████████████████████| 56.9 MB 2.2 MB/s Collecting pyqt5-plugins<5.15.2.3,>=5.15.2.2 Downloading http://mirrors.aliyun.com/pypi/packages/52/b7/10aeef6008d16ce027759b83776a2c24504bf66cde38b4a96d3f34839137/pyqt5_plugins-5.15.2.2.1.0-cp38-cp38-win_amd64.whl (65 kB) |████████████████████████████████| 65 kB 4.5 MB/s Collecting python-dotenv Downloading http://mirrors.aliyun.com/pypi/packages/86/62/aacbd1489fc6026c9278e9fd5cfdd49c5b1b5375d3c97a624e8f8f999eb2/python_dotenv-0.17.0-py2.py3-none-any.whl (18 kB) Requirement already satisfied: PyQt5-sip<13,>=12.8 in d:\study\python380\lib\site-packages (from pyqt5==5.15.2->PyQt5-tools) (12.8.1) Collecting qt5-tools<5.15.2.2,>=5.15.2.1 Downloading http://mirrors.aliyun.com/pypi/packages/4f/9f/627ee838664ad9b01c5db2c4274d3e68f18f78331b6ba61f770cc4435e67/qt5_tools-5.15.2.1.0.1-py3-none-any.whl (12 kB) Collecting qt5-applications<5.15.2.3,>=5.15.2.2 Downloading http://mirrors.aliyun.com/pypi/packages/21/bc/caa266764d44955a0d908f6b1ca349af4b72e93a15a4b5feeba6df2aa980/qt5_applications-5.15.2.2.1-py3-none-win_amd64.whl (61.0 MB) |████████████████████████████████| 61.0 MB 3.3 MB/s Installing collected packages: qt5-applications, click, qt5-tools, pyqt5, python-dotenv, pyqt5-plugins, PyQt5-tools Attempting uninstall: pyqt5 Found existing installation: PyQt5 5.15.4 Uninstalling PyQt5-5.15.4: Successfully uninstalled PyQt5-5.15.4 Successfully installed PyQt5-tools-5.15.2.3.0.2 click-7.1.2 pyqt5-5.15.2 pyqt5-plugins-5.15.2.2.1.0 python-dotenv-0.17.0 qt5-applications-5.15.2.2.1 qt5-tools-5.15.2.1.0.1
-
添加環(huán)境變量
- 將
designer.exe
目錄添加到環(huán)境變量 (可在cmd中輸入path確認(rèn))
- 將
不同版本designer.exe的所在路徑可能不一樣。安裝過三次,每次都不一樣,因此可以在pyqt的幾個目錄下找一下
designer
- 測試PyQt5環(huán)境是否安裝成功
執(zhí)行腳本之后彈出一個窗口(Widget)界面,則說明PyQt5環(huán)境安裝成功。import sys from PyQt5 import QtWidgets, QtCore app = QtWidgets.QApplication(sys.argv) widget = QtWidgets.QWidget() widget.resize(360, 360) widget.setWindowTitle('Hello, PyQt5') widget.show() sys.exit(app.exec_())
-
PyQt5的依賴模塊
- 在cmd中進入Python交互窗口然后輸入語句
import PyQt5
和help(PyQt5)
. - 其中的PACKAGE CONTENTS就是其依賴模塊。
C:\Users\admin>python Python 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:37:50) [MSC v.1916 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import PyQt5 >>> help(PyQt5) Help on package PyQt5: NAME PyQt5 DESCRIPTION # Copyright (c) 2020 Riverbank Computing Limited <info@riverbankcomputing.com> # # This file is part of PyQt5. # # This file may be used under the terms of the GNU General Public License # version 3.0 as published by the Free Software Foundation and appearing in # the file LICENSE included in the packaging of this file. Please review the # following information to ensure the GNU General Public License version 3.0 # requirements will be met: http://www.gnu.org/copyleft/gpl.html. # # If you do not wish to use this file under the terms of the GPL version 3.0 # then you may purchase a commercial license. For more information contact # info@riverbankcomputing.com. # # This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE # WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. PACKAGE CONTENTS QAxContainer Qt QtBluetooth QtCore QtDBus QtDesigner QtGui QtHelp QtLocation QtMultimedia QtMultimediaWidgets QtNetwork QtNetworkAuth QtNfc QtOpenGL QtPositioning QtPrintSupport QtQml QtQuick QtQuick3D QtQuickWidgets QtRemoteObjects QtSensors QtSerialPort QtSql QtSvg QtTest QtTextToSpeech QtWebChannel QtWebSockets QtWidgets QtWinExtras QtXml QtXmlPatterns _QOpenGLFunctions_2_0 _QOpenGLFunctions_2_1 _QOpenGLFunctions_4_1_Core pylupdate pylupdate_main pyrcc pyrcc_main sip uic (package) FILE d:\study\python380\lib\site-packages\pyqt5\__init__.py
- 在cmd中進入Python交互窗口然后輸入語句