Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to build and configure PyQt5 environment in VSCode

2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article is about how to build and configure the PyQt5 environment in VSCode. I think it is very practical, so I share it with you. I hope you can get something after reading this article. Let's take a look at it.

How to build and configure PyQt5 environment in VSCode? The following article introduces the installation of the PyQt5 toolkit and how to configure the PyQt5 environment in VSCode. I hope it will be helpful to those who need it!

Record the process of setting up the environment when learning QT. QT interface programming I know that there are python version, but also C++ version, here I choose the python version of PyQt5

1. PyQt5 toolkit installation

Your own python environment has been installed by default here.

Use the pip command to install the PyQt5 tool-pip install pyqt5

Reinstall the development tools QT designer--pip install pyqt5-tools

The installation path is\ Lib\ site-packages under your python installation path

Find the pyqt5designer.exe file under this path

This is the Qt Designer graphical interface development tool, you can choose to generate a shortcut to the desktop, and then double-click to use it.

2. Visual Studio Code configuration

Visual Studio Code, it only takes two steps here. [recommended study: "getting started with vscode"]

Download and install the plug-in PYQT integration

Set the path of pyqt5designer.exe to the default open location

Click the gear in the lower left corner to open the settings, search pyqt directly, open the PYQT integration configuration in the extension, find the two options Pyqt integration Pyuic: Cmd and Pyqt integration Qtdesigner Path, and add the absolute path of the previous pyqt5designer.exe (I moved it to another location here)

3. Use PyQt5 in Visual Studio Code

You can use pyqt5designer for layout directly, or you can design it with your own code.

Use of pyqt5designer: you can double-click pyqt5designer.exe directly to open the development tool (if you have generated shortcuts before)

For the sake of desktop cleanliness, I didn't generate it. Instead, I used the plug-in I just installed. Right-click PYQT: new form in the left file bar to quickly open the development interface.

Then add any control and save a .ui file

Return to vscode, open the corresponding folder, click on the .ui file, right-select PYQT: Compile Form, and generate the corresponding .py file. This is the corresponding py code that just designed the layout. Beginners like me can use it to learn the layout code.

Directly tap the code: at the beginning, I learned from other bloggers that the basic control use and layout are their own manual code code, the feeling of their own code is still a little stronger, and it is more interesting to study. Let's talk about a problem that I have encountered here-- that is, import pyqt5 will report an error, but in fact, there is no error, and it can work normally.

And then found a solution in the article of Muzi Huaner (https://blog.csdn.net/muzihuaner/article/details/106205930)

That is, create a new .pylintrc file and type in the following code, and the problem will be solved perfectly.

Extension-pkg-whitelist=PyQt5

The above is how to build and configure the PyQt5 environment in VSCode. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

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.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report