In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
This article introduces the relevant knowledge of "how to install pyqt5 and its related configuration with pycharm". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
First, configure a special virtual environment
Reason: different projects use different versions of python, depending on the version of the library is also different, in order to avoid version conflicts, so for each project each version of python to create a virtual environment, the environment used by dependent libraries also exist independently, will not be affected by other versions or other project libraries.
1. Create a separate folder to store pyqt5 code and create a virtual environment
I set up a folder called python on the F disk and a folder python-pyqt5 in this folder to store the code. At this time, the python-pyqt5 is empty and there are no files.
2. Enter pycharm and open the python-pyqt5 project
Step: click File-- > Click Open-- > find the folder you just created (python-pyqt5)-> Click OK
3. Configure the virtual environment
1. Click the Terminal below to enter the terminal (you must make sure that the path displayed on the terminal is the same as that of the folder)
two。 Enter on the terminal
This is to create a virtual environment.
Python-m venv venv
3. At this point, in the Project project, python-pyqt5 can see a folder called venv, which is the virtual environment.
Configure a virtual python environment
Step: 1. Click File-- > Settings
2. Find Project:python-pyqt5-- > Project Interpreter (project interpreter)-> Add (add interpreter)
3. Click Virtualenv Environment-- > Existing environment-- > Interpreter
The interpreter here chooses the path of the virtual interpreter we created, and finally includes python.exe
Click Ok all the way back to Project Interpreter (project interpreter), and you will find that the interpreter has now been created, and there are only two default libraries here. Finally, click Apply at the bottom right, and then click OK.
Never mind the "(2)" here, this is because I have created a second interpreter of this. If it is created for the first time, there is no "(2)" here.
Install pyqt5 and pyqt5-tools tools
When you open a terminal, you want to display the venv, so that the virtual interpreter is configured successfully, indicating that the current environment is a virtual environment.
This installation is the use of domestic sources, Douban network for installation, the installation speed will be very fast
1. Install: pyqt5pip install pyqt5-I https://pypi.douban.com/simple/
The appearance of Successfully means that the installation is successful and the yellow one is not needed. This is a warning and generally tells pip that it needs to be updated.
2. Install: pyqt5-toolspip install pyqt5-tools-I https://pypi.douban.com/simple/
4. Configure system environment variables
1. Click: control panel right-click-> Click system-> Advanced system Settings-> system variable-> Path
2. Open the interface from the folder to the virtual environment
Search here:
3. Search: designer.exe
4. Right-click-- > Open the location of the file
5. Copy the above path: F:\ python\ python-pyqt5\ venv\ Lib\ site-packages\ qt5_applications\ Qt\ bin
Add to the environment variable
6. Search again: plugins
7. Click the last file and right-click-- > go to the location of the file.
Click plugins to enter the folder:
8. Copy path: F:\ python\ python-pyqt5\ venv\ Lib\ site-packages\ PyQt5\ Qt5\ plugins
And add it to the system variable
Variable name: QT_QPA_PLATFORM_PLUGIN_PATH
Variable values: path
5. Configure Qt Designer
Enter pycharm, click File-- > click Settings-- > Tools-- > External Tools
Add the name of the extra component
Name:
Qt Designer
The path to the extra component, which is the path to designer.exe
Program::
F:\ python\ python-pyqt5\ venv\ Lib\ site-packages\ qt5_applications\ Qt\ bin\ designer.exe
Work path:
Method 1:
Working directory:
$FileDir$
Method 2:
Working directory:F:\ python\ python-pyqt5
Because I configured the first one to report an error, and the path did not exist, so I changed to the second method, filling in an actual path
Go to the initial interface and click as follows:
When the configuration is successful, the run will not report an error, and an interface will appear
The appearance of such an interface means that the Qt Designer is configured successfully.
6. Configure PyUIC
PyUIC: this is to encode the interface we set to the .py file.
Click File-- > click Settings-- > Tools-- > External Tools-- > click + again
Add the name of the extra component
Name:
PyUIC
Path to additional components
Program:
F:\ python\ python-pyqt5\ venv\ Scripts\ pyuic5.exe
Arguments:
$FileName$-o $FileNameWithoutExtension$.py-x
Work path:
Note: this work path should be consistent with the Qt Designer work path configured above.
Working directory:F:\ python\ python-pyqt5
After the configuration is successful, click on the following steps, and if the configuration is successful, a .py file will appear in the folder, which is a success.
Contents of .py file
VII. matters needing attention
1. The .ui file must be available before PyUIC conversion can be carried out, otherwise an error will be reported.
2. The environmental variables of the system must be correct.
3. The pyqt5 files according to different python may be different, but they are basically the same, except that the path of the file is different.
This is the end of the introduction to "how to install pyqt5 and its related configurations with pycharm". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.