Get the App
SLTechnology News&Howtos  ›  Development  › 

How to configure VSCode to run python

Shulou Source: shulou.com Published: 2022-06-01 13:02:50 10月01日 Update

This article mainly explains "how to configure VSCode to run python". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to configure and run python in VSCode".

Preparation stage

First install the corresponding VSCode and python interpreters, and then install the following plug-in.

Pylance is a new python plug-in from Microsoft, which is used to replace the original python plug-in. With this plug-in, you can run python code in VSCode.

Search for pylance in the expansion store, click install, and restart VSCode.

Project creation and configuration

Create a new folder, open it with VSCode, and then create a new py code file (take hello world as an example).

Click Select Python Interpreter at the bottom to select your own python environment.

After the selection is completed, a .vscode folder will appear in the project directory, and a setting.json file will appear in it, with the following structure:

{"python.pythonPath": "C:\\ Program Files\\ Python39\ python.exe"}

If you need to change the interpreter, you can change the above interpreter path to the interpreter path you need.

Running

Once you have configured the python interpreter, you can run the python file.

Click the run button in the upper right corner (green triangle) and the code will run.

Thank you for reading, the above is the content of "how to configure and run python in VSCode". After the study of this article, I believe you have a deeper understanding of how to configure and run python in VSCode, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Runs configurations files interpreters interpreters plug-ins code folders learning content paths choices triangles stores that is ideas situations buttons articles more Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi vpn Huawei NVidia macOS