Python3.8+PyQt5+pyqt5-tools+Pycharm配置+将ui文件转py文件
个人使用环境
本人使用环境:
win 8
python 3.8
pycharm 2019.xx.xx
安装过程
1. 安装PyQt5
使用镜像源快速安装PyQt5:
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple PyQt5
2. 安装pyqt5-tools
使用镜像源快速安装pyqt5-tools:
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pyqt5-tools
最好连这几个库都安装一下SIP、PyInstaller、PyQt5-sip
3. 查看
安装完PyQt5、pyqt5-tools后到Python的安装目录中查看,路径因人而异。例如:
D:\Programs\Python\Python38\Lib\site-packages
查看是否存在PyQt5、pyqt5-tools文件夹,并且在pyqt5-tools下的Qt\bin下是否存在designer.exe
若点击designer.exe存在以下报错,说明未创建环境变量!
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
4. 创建环境变量
在环境变量中的系统变量新建
变量名 QT_QPA_PLATFORM_PLUGIN_PATH
变量值 D:\Programs\Python\Python38\Lib\site-packages\PyQt5\Qt\plugins
变量值为个人python的安装路径,具体因人而异!
创建完后再去相应目录下点击打开designer.exe
D:\Programs\Python\Python38\Lib\site-packages\pyqt5_tools\Qt\bin\designer.exe
配置过程
1. 打开Pycharm
File ==> Settings ==> Tools ==> External Tools 点击“+” 进行创建
2. 配置QtDesigner
Name:QtDesigner
Program:D:\Programs\Python\Python38\Scripts\pyqt5designer.exe
#这里输入你的python安装路径下的Scripts\pyqt5designer.exe就好
Working directory:$ProjectFileDir$
点击OK
3. 配置pyuic5
Name:pyuic5
Program:D:\Programs\Python\Python38\Scripts\pyuic5.exe
#这里输入你的python安装路径下的Scripts\pyuic5.exe就好
Arguments:$FileName$ -o $FileNameWithoutExtension$.py
Working directory:$FileDir$
点击OK
4. 配置pyrcc5
Name:pyrcc5
Program:D:\Programs\Python\Python38\Scripts\pyrcc5.exe
#这里输入你的python安装路径下的Scripts\pyrcc5.exe就好
Arguments:$FileName$ -o $FileNameWithoutExtension$.py
Working directory:$FileDir$