Building a pyqt5 development environment under Linux—based on Pycharm

Anti-stepping pit Tips:

1. You can't install PyQt5Designer and pyqt5-tools directly with pip like Windows. The most fundamental of these two modules is the windows program, which cannot be run on linux, especially PyQt5Designer, which will prompt that the installation fails.

2. It is recommended to install pyqt with the same system version in the python environment. For example, the default installed pyqt version under ubuntu18.04 is 5.10.1, and the corresponding version can also be installed in the python environment pip install PyQt5==5.10.1

3. If you install opencv, it is recommended to use pip to install, not conda to install, because conda will install qt-main, etc., the version may be inconsistent with the pyqt version, resulting in conflict errors.

1. Install pyqt5 and qt5 development tools

sudo apt install pyqt5* qttools5-dev-tools

Second, then configure the Pycharm extension tool

Click on File in the upper left corner --> Settings

Tools --> External Tools --> "+" sign

Create a project named pyuic with the following parameters:

Copy to yourself

pyuic
/usr/bin/pyuic5
$FileName$ -o $FileNameWithoutExtension$.py
$FileDir$

Create a project named QtDesigner with the following parameters: 

 

Copy to yourself

QtDesginer
/usr/lib/x86_64-linux-gnu/qt5/bin/designer
$FileDir$

3. Install pyqt5 in a virtual environment

It is recommended to install the same version of pyqt as the system. For example, the default version of pyqt installed under ubuntu18.04 is 5.10.1, and the corresponding version can also be installed in the python environment. pip install PyQt5==5.10.1

You can also create a Python project in pycharm, and open the project after creation. Click  Python Packages  , search for pyqt5, click Install, and the installation is successful if it is displayed.

(Note that the pyqt5 installed here is the virtual environment of the current project. If you recreate a project, you need to install it again)

At this point, the environment is built.

Reference: https://www.cnblogs.com/syxy/p/15375800.html

Guess you like

Origin blog.csdn.net/dou3516/article/details/131826066