VSCode installation and environment configuration detailed tutorial (windows version)

Table of contents

Install VSCode

Install Python

Check environment variables

Check if Python can run

VSCode environment configuration

Switch to Simplified Chinese

Add Python plugin

write code to run


! ! Please download the Python and VSCode installation packages from the official website first, and save them locally

Python official website: https://www.python.org/downloads/

Choose the appropriate version according to your computer system.

 

 VS Code官网:Download Visual Studio Code - Mac, Linux, Windows

I installed Python3.8.8 and VS Code 1.69.2, and I can download resources directly.

  • Install VSCode

Double-click the VSCode installation package, click "I agree to this agreement", and then click "Next".

If there is no location in the c drive, you can modify the installation path (it is recommended to install to another drive to avoid the c drive being too full), and click "Next" after modification.

Click "Next".

Be sure to check "Add to Path " , others can also be checked, and then click "Next"

Click "Install".

Wait patiently for the installation to finish. After the installation is complete, there is no need to run VSCode.

  • Install Python

Double-click to run the installation package, you must check " Add python 3.8.exe to PATH " , and then select "Customize Installation".

Check the options in the figure, and click "Next".

It is recommended to choose the first 5 . In addition, the installation path can be changed here (do not appear Chinese in the installation path, the operation of Python itself should not be affected by the Chinese path, but many library functions will). After setting, click "Install".

If there is this "Disable path length limit" after the installation is complete, click it to save trouble later.

After installation, click "close" to complete the installation.

  • Check environment variables

Restart the computer first. Next, check whether the environment variables of VSCode and Python are set. There are two ways to open system environment variable settings:

1) If there is a search box in the lower left corner, just search for "environment variable" directly

2) If not, you can find the computer, right mouse button and select "Properties", after opening the interface, slide down and select "Advanced System Settings"

After opening, select "Advanced" - "Environment Variables".

You can see that the upper part is "user variable", and the lower part is "system variable", the difference is as shown in the figure. Highlight Path and click Edit.

Check whether there are three paths boxed out in the environment variable, namely Python38, Python38\Scripts, Microsoft VS Code\bin. If there is, you can turn it off, if not, add it manually.

  • Check if Python can run

Next, we check that the Python we just installed works properly. Here are three ways to open the command line window cmd.

1) If there is a search box in the lower left corner, search for cmd directly to open it.

2) If not, click the system icon in the lower left corner, find the Windows system, and select Command Prompt to open it.

3) Press the shortcut key Win+R, then enter cmd and press Enter.

After entering the command prompt, enter python --version to view the version of Python installed on the computer.

Then enter pip list to see which libraries are currently installed. Because we checked install pip when installing Python, there is a library of pip at this time, and we need to use pip xxx ( library name ) to install other third-party libraries later .

  • VSCode environment configuration

  1. Switch to Simplified Chinese

When we open VSCode, the interface is usually in English when entering for the first time, and you will be prompted to install the Chinese extension in the lower right corner, just click it. Or search for "Chinese Simplififed" in the "Extension" option on the left, install the first plug-in, restart after installation, and the interface will be in Chinese.

After restarting, it will automatically switch to the Chinese interface.

  1. Add Python plugin

Since we are writing Python in VSCode for the first time, we need to install the required plug-ins in VSCode. Search for Python in the extension page on the left (click the fifth button), and the first search result is the Python plug-in, just click to install it.

At this time, "Install recommended extensions for Python" will appear in the lower right corner. Click Install, and it will help us install related plug-ins such as Pylance and Jupyter Notebook.

After installation, we can view our installed plugins in the installed list.

  • write code to run

Let's write code to check whether the environment is configured successfully. In the start on the right side of the interface, we will be prompted to choose a Python interpreter. We can click "Select Python Interpreter" and choose the Python3.8.8 we just installed. (If other versions of the Python interpreter are installed, multiple options will appear here)

Next, we create a new text file, and we will be prompted to choose a language on the page. We enter Python in the input box, and then select.

Then we write the first line of code:

print ( "Hello World" ), click this triangle icon to run

Then press Ctrl+S to save , if you click Run directly, you will also enter the save page. Let's name the file test.

Click Run (the triangle icon in the upper right corner), and you can view the output results in the terminal at the bottom of the interface.

At this point, the installation and environment configuration of VS Code is complete.

Guess you like

Origin blog.csdn.net/weixin_42149550/article/details/131666425