Python VScode Configuration
In the previous chapter, we installed the Python environment. In this chapter, we will introduce the configuration of Python VScode.
- Install VS Code
- Install VS Code Python Extension
- Install Python 3
Install VS Code
VSCode (full name: Visual Studio Code) is a free, cross-platform source code editor developed by Microsoft. The VSCode development environment is very simple and user-friendly.
Installing VSCode is straightforward. Open the official website https://code.visualstudio.com/, download the software package, and follow the steps to install. During the installation, pay attention to the installation path settings and ensure that the environment variables are automatically added to the system. Make sure to check all the options.
For a complete installation guide, refer to: https://www.tutorialpro.org/w3cnote/vscode-tutorial.html
Next, we install the VS Code Python
extension:
Create a Python Code File
Open VScode, then click on New File:
Click to select the language:
In the search box, type Python and select the Python option:
Enter the code:
print("tutorialpro")
Right-click the mouse and choose to run the file in the interactive window. If prompted to install an extension, simply click install (if not installed, it will keep showing as connecting to the Python kernel):
Alternatively, you can open an existing file or directory (folder), such as opening a tutorialpro-test, or you can create one yourself:
Then, create a test.py file by clicking the new file icon and enter the file name test.py:
Note: The tutorialpro-test contains a .vscode
folder, which includes some configuration information. You can ignore it for now.
Enter the following code in test.py:
print("tutorialpro")
Click the green icon in the upper right corner to run:
You can also right-click the file and select "Run Python File in Terminal":
Alternatively, you can right-click in the code window and select "Run Python File in Terminal".