PyQt5學(xué)習(xí)筆記1 - Windows下安裝PyQt5

Windows下安裝PyQt5

安裝Python

往期文章

python 基礎(chǔ)篇章1-安裝

安裝PyQt5

概述:pip 安裝PyQt5, PyQt5-tools

  1. 安裝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
    
  2. 安裝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
    
  3. 添加環(huán)境變量

    • designer.exe目錄添加到環(huán)境變量 (可在cmd中輸入path確認(rèn))

不同版本designer.exe的所在路徑可能不一樣。安裝過三次,每次都不一樣,因此可以在pyqt的幾個目錄下找一下

designer
  1. 測試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_())
    
    執(zhí)行腳本之后彈出一個窗口(Widget)界面,則說明PyQt5環(huán)境安裝成功。
  1. PyQt5的依賴模塊

    • 在cmd中進入Python交互窗口然后輸入語句import PyQt5help(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
    

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市区转,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌版扩,老刑警劉巖废离,帶你破解...
    沈念sama閱讀 217,277評論 6 503
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異礁芦,居然都是意外死亡蜻韭,警方通過查閱死者的電腦和手機悼尾,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,689評論 3 393
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來肖方,“玉大人闺魏,你說我怎么就攤上這事「┗” “怎么了析桥?”我有些...
    開封第一講書人閱讀 163,624評論 0 353
  • 文/不壞的土叔 我叫張陵,是天一觀的道長艰垂。 經(jīng)常有香客問我泡仗,道長,這世上最難降的妖魔是什么猜憎? 我笑而不...
    開封第一講書人閱讀 58,356評論 1 293
  • 正文 為了忘掉前任娩怎,我火速辦了婚禮,結(jié)果婚禮上胰柑,老公的妹妹穿的比我還像新娘截亦。我一直安慰自己,他們只是感情好旦事,可當(dāng)我...
    茶點故事閱讀 67,402評論 6 392
  • 文/花漫 我一把揭開白布魁巩。 她就那樣靜靜地躺著急灭,像睡著了一般姐浮。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上葬馋,一...
    開封第一講書人閱讀 51,292評論 1 301
  • 那天卖鲤,我揣著相機與錄音,去河邊找鬼畴嘶。 笑死蛋逾,一個胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的窗悯。 我是一名探鬼主播区匣,決...
    沈念sama閱讀 40,135評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼蒋院!你這毒婦竟也來了亏钩?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 38,992評論 0 275
  • 序言:老撾萬榮一對情侶失蹤欺旧,失蹤者是張志新(化名)和其女友劉穎姑丑,沒想到半個月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體辞友,經(jīng)...
    沈念sama閱讀 45,429評論 1 314
  • 正文 獨居荒郊野嶺守林人離奇死亡栅哀,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,636評論 3 334
  • 正文 我和宋清朗相戀三年震肮,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片留拾。...
    茶點故事閱讀 39,785評論 1 348
  • 序言:一個原本活蹦亂跳的男人離奇死亡戳晌,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出痴柔,到底是詐尸還是另有隱情躬厌,我是刑警寧澤,帶...
    沈念sama閱讀 35,492評論 5 345
  • 正文 年R本政府宣布竞帽,位于F島的核電站扛施,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏屹篓。R本人自食惡果不足惜疙渣,卻給世界環(huán)境...
    茶點故事閱讀 41,092評論 3 328
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望堆巧。 院中可真熱鬧妄荔,春花似錦、人聲如沸谍肤。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,723評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽荒揣。三九已至篷角,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間系任,已是汗流浹背恳蹲。 一陣腳步聲響...
    開封第一講書人閱讀 32,858評論 1 269
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留俩滥,地道東北人嘉蕾。 一個月前我還...
    沈念sama閱讀 47,891評論 2 370
  • 正文 我出身青樓,卻偏偏與公主長得像霜旧,于是被迫代替她去往敵國和親错忱。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 44,713評論 2 354

推薦閱讀更多精彩內(nèi)容