zoukankan      html  css  js  c++  java
  • PyQt5的安装及测试(pycharm)

    1.安装pythom(略)

    2.安装pycharm(略)

    3.安装pyqt5 designer汉化

    3.1首先是安装pyqt5

    pip install PyQt5

    如出现错误:

    ERROR: THESE PACKAGES DO NOT MATCH THE HASHES FROM THE REQUIREMENTS FILE. If you have updated the package versions, please update the hashes. Otherwise, examine the package contents carefully; someone may have tampered with them.
        PyQt5 from https://files.pythonhosted.org/packages/1f/0e/d0390f7ac55c3d4ac041cbdb13fa2b03225a7f8856d52f712e7e398b2208/PyQt5-5.13.2-5.13.2-cp35.cp36.cp37.cp38-none-win32.whl#sha256=14737bb4673868d15fa91dad79fe293d7a93d76c56d01b3757b350b8dcb32b2d:
            Expected sha256 14737bb4673868d15fa91dad79fe293d7a93d76c56d01b3757b350b8dcb32b2d
                 Got        c2886891b8915741ee3103cec3156d5282b22e5766187151b139e2044cedb248
    
    WARNING: You are using pip version 19.2.3, however version 19.3.1 is available.
    You should consider upgrading via the 'python -m pip install --upgrade pip' command.

     输入

    python -m pip install --upgrade pip

    再输入

    pip install PyQt5

    安装成功!

    3.2 安装Qt工具

    pip install PyQt5-tools

    如出现下面错误

    ERROR: Could not find a version that satisfies the requirement PyQt5-tools (from versions: none)
    ERROR: No matching distribution found for PyQt5-tools

    解决方法如下:

    https://pan.baidu.com/s/1GVhquhTe5bgrjGRvUVRloQ 提取码:ain0 
    或者https://github.com/xdd1997/Download-or-Picture/blob/master/PyQt5_Tools-5.7.dev1-py3-none-any.whl
    下载后得到一个.whl文件 将上面文件放在'C:WindowsSysWOW64 目录下 WIN+R输入cmd,回车打开命令提示符: 输入:pip install wheel 然后:pip install PyQt5_Tools-5.7.dev1-py3-none-any.whl 至此就成功安装了pyqt5-tools

    安装完成之后先确认一下安装位置,因为之后用的上,正常的话,会在你的python的安装目录下的

    pythonx.xLibsite-packages目录下,如图:

    3.3 安装安装QtDesigner

    然后进入pycharm的File下的settings->Tools->External Tools 点加号,

    Name:QtDesigner  
    Program:之前PyQt5-tools目录下的designer.exe文件 
    如我的E:Python38Libsite-packagesPyQt5-toolsdesigner
    designer.exe
    2020-06-14更新:E:Program Filespython3.7.4Libsite-packagespyqt5_toolsQtindesigner.exe
    2020-12-1更新:C:Xddsoftwarepython39Libsite-packagesqt5_applicationsQtindesigner.exe
    Working directory:$FileDir$

    3.4安装PyUIC

    进入pycharm的File下的settings->Tools->External Tools 点加号,

    Name:PyUIC  
    Program:选择python.exe的文件路径 如我的:E:Python38python.exe
    
    Argument:
    -m
    PyQt5.uic.pyuic
    $FileName$
    -o
    $FileNameWithoutExtension$.py
    
    Working directory:$FileDir$

    3.5安装PyRCC

    进入pycharm的File下的settings->Tools->External Tools 点加号,

    Name:PyRCC  
    Program:python目录下的Script下的pyrcc5.exe的目录
    
    Argument:
    $FileName$
    -o
    $FileNameWithoutAllExtensions$.py
    
    Working directory:$FileDir$

    3.6 designer汉化

    https://blog.csdn.net/Wonz5130/article/details/83594231

     

     

    over,over,over!

    代码测试

     

    import sys
    from PyQt5.QtWidgets import*
    if __name__=='__main__':
        #创建QApplication实例
        app = QApplication(sys.argv)
        #创建一个窗口
        w = QWidget()
        #设置窗口尺寸
        w.resize(300,150)
        #移动窗口
        w.move(300,300)
        #设置窗口标题
        w.setWindowTitle('第一个基于PyQt5的桌面应用')
        #显示窗口
        w.show()
        #进入程序的主循环,并通过exit函数确保主循环安全结束
        sys.exit(app.exec_())

     

    能显示窗口则正常,如出现找不到模块,参考下面解决方法:

    PyQt5安装及ModuleNotFoundError: No module named 'PyQt5'问题解决_SunnyFish-ty的博客-CSDN博客
    https://blog.csdn.net/qq_33485434/article/details/80606359

    推荐学习视频  https://www.bilibili.com/video/av54310770

     


    转载仅为学习,不会商用。
    欢迎转载原创,附文链接。
  • 相关阅读:
    PAT (Advanced Level) 1017. Queueing at Bank (25)
    PAT (Advanced Level) 1016. Phone Bills (25)
    1sting
    八皇后问题
    思维水题
    pigofzhou的巧克力棒
    喵哈哈村的代码传说 第四章 并查集
    简单容器应用
    Codefroces D2. Magic Powder
    喵哈哈村的种花魔法(线段树(区间更新,单点查询),前缀和(单点更新,区间查询))
  • 原文地址:https://www.cnblogs.com/xdd1997/p/11921946.html
Copyright © 2011-2022 走看看