pyqt5的安装
第一步:需要安装:pip3 install pyqt5
pip install pyQt5 -i http://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com 阿里云镜像下载
安装工具:pip3 install pyqt5-tools
pip3 install pyqt5-tools -i http://mirrors.aliyun.com/pypi/simple --trusted-host mirrors.aliyun.com 阿里云镜像下载
解决pip安装pyqt报错:Building wheel for PyQt5-sip (pyproject.toml) did not run successfully
解决报错:Could not build wheels for PyQt5-sip,which is required to install pyproject.toml-based projects
卸载pyqt5: pip3 uninstall pyqt5
第二步:打开Pycharm,进入设置,添加外部工具
菜单-->文件file-->设置settings-->工具Tools-->外部工具External Tools-->
添加QtDesigner
在Name(名称)处:QtDesigner
在Program(程序):
C:\python3.7\Lib\site-packages\qt5_applications\Qt\bin\designer.exe [改成自己designer.exe所在的目录]
在Arguments(实参): $FileDir$\$FileName$
在working directory(工作目录):$FileDir$
再点加号,添加pyuic5的参数,这个是把qt的UI文件转换成.py文件的工具
在在Name处:pyuic5
program: D:\python64\Scripts\pyuic5.exe,这个也需要改成你自己的
arguments:$FileName$ -o $FileNameWithoutExtension$.py
working directory:$FileDir$
再点加号,添加pyrcc的参数,这个是将资源文件如图片等转成python代码能识别的文件,这个参数基本和pyuic5的是一样的
在Name:pyrcc
program: D:\python64\Scripts\pyrcc5.exe,这个也需要改成你自己的
arguments:$FileName$ -o $FileNameWithoutExtension$.py
working directory:$FileDir$
活动模板:
No module named 'PyQt5' 解决办法
打开该项目,在项目中找到venv目录,把pyvenv.cfg文件中的如下参数改成true
include-system-site-packages = true