參考鏈接:
https://www.cnblogs.com/pywjh https://blog.csdn.net/SeekAndFindYou
https://www.cnblogs.com/lsdb/p/9122425.html
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:\Windows\SysWOW64\ 目錄下 WIN+R輸入cmd,回車打開命令提示符: 輸入:pip install wheel 然后:pip install PyQt5_Tools-5.7.dev1-py3-none-any.whl 至此就成功安裝了pyqt5-tools
安裝完成之后先確認一下安裝位置,因為之后用的上,正常的話,會在你的python的安裝目錄下的
\pythonx.x\Lib\site-packages目錄下,如圖:
3.3 安裝安裝QtDesigner
然后進入pycharm的File下的settings->Tools->External Tools 點加號,
Name:QtDesigner Program:之前PyQt5-tools目錄下的designer.exe文件 如我的E:\Python38\Lib\site-packages\PyQt5-tools\designer\designer.exe
2020-06-14更新:E:\Program Files\python3.7.4\Lib\site-packages\pyqt5_tools\Qt\bin\designer.exe
Working directory:$FileDir$
3.4安裝PyUIC
進入pycharm的File下的settings->Tools->External Tools 點加號,
Name:PyUIC Program:選擇python.exe的文件路徑 如我的:E:\Python38\python.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_())
能顯示窗口則正常,有問題再花些時間改改吧
推薦學習視頻 https://www.bilibili.com/video/av54310770