提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档
目录
PyQt5环境配置
1. conda 创建虚拟环境
1. 1 create a new virtual environment with specific python version (take python=3.8 as the example)
- Open command prompt in windows (recommend to run as administrator)
- Input the following command (py38 is the user-defined environment name):
conda create -n py38 python=3.8
- Activate the installed environment
conda activate py38
2 install pyQT5 and pyQT5-tools
pip install pyqt5
pip install pyqt5-tools
3. Verify the installation of pyQT5
- Type python in the command line to enter python environment
- input the following code to test wheter the pyqt is successfully installed
from PyQt5.QtWidgets import QApplication, QDialog
- if no error appear, it works
4. Configurate QT Designer, pyUIC and pyRCC in pycharm
- QT designer provide a graphic interface to speed up the UI design
- PyUIC is used to convert .ui file to .py file
- PyRCC is used to convet figures, data. i.e. other resources to .py file
4.1 Open Pycharm, navigate to File -> Settings -> External Tools
4.2 Add Qt Designer
- look up the designer.exe in the py38 virtual environment folder, it should locate at
…\anaconda3\envs\py38\Lib\site-packages\qt5_applications\Qt\bin\designer.exe
- configuration
- Name: QtDesigner (user-defined)
- Arguments: $FileDir$\$FileName$
- Woring directory: $FileDir$
4.3 Add pyuic5
- look up the pyuic5.exe in the py38 virtual environment folder, it should locate in
…\anaconda3\envs\py38\Scripts\pyuic5.exe
- Configuration
- Name: PyUic (user-defined)
- Arguments: $FileName$ -o $FileNameWithoutExtension$.py
- Woring directory: $FileDir$
4.3 Add pyrcc5
- look up the pyuic5.exe in the py38 virtual environment folder, it should locate in
…\anaconda3\envs\py38\Scripts\pyrcc5.exe
- Configuration
- Name: PyUic (user-defined)
- Arguments: $FileName$ -o $FileNameWithoutExtension$.py
- Woring directory: $FileDir$