In order to install Visual Studio Code, you can download it free of charge from the following address:
https://visualstudio.microsoft.com/
When the download is complete, run the corresponding installer.
Notice: Keep in mind that Python must be present on your computer. If you haven’t installed Python, install it following the steps described here.
In the popup window that appears (Figure 1), you must accept the terms of the License Agreement and click on the “Next” button.
Figure 1 Accepting the terms of the License Agreement
The Visual Studio Code installer (as shown in Figure 2) prompts you to select where Visual Studio Code should be installed. Keep the proposed folder and click on the “Next” button.
Figure 2 Selecting the Destination Location
Notice: The installation folder (Destination Location) proposed on your computer may differ from that in Figure 2 depending on the versions of the Visual Studio Code or Windows that you have.
On the next screen (Figure 3), you can select where the installer should place the program’s shortcuts. Click on the “Next” button.
Figure 3 Selecting Start Menu Folder
On the next screen, you can select the additional tasks you would like the installer to perform. Make sure that the “Add to PATH (requires shell restart)” option is checked (as shown in Figure 4) and click on the “Next” button.
Figure 4 Selecting Additional Tasks
On the next screen, click on the “Install” button.
When the installation process is complete, launch Visual Studio Code.
When Visual Studio Code opens, you can choose the look you want (Figure 5). Click on the “Mark Done” button.
Figure 5 Choosing the look you want
Click on the “Extensions” button in the Activity Bar on the left. In the Side Bar that opens, search for “Python” (as shown in Figure 6) and click on the “Install” button and wait for the installation to complete. It is advisable to install the Python extension that is developed by Microsoft.
Figure 6 Searching for the Python extension in Visual Studio Code
Next, you must add a folder to the workspace. Click on the “Explorer” button in the Activity Bar on the left. In the Side Bar that opens, click on the “Open Folder” button, as shown in Figure 7.
Figure 7 Adding a folder to the workspace
Open (select) an empty folder where your projects should be stored. If a popup window opens asking you if you trust the authors of this folder, you should click on the “Yes, I trust the authors” button.
Notice: It is a good idea to create a folder named “VS Code Python Projects” in your Documents folder and add that folder to the workspace.
Next, hit the CTRL + SHIFT + P key combination to open the Command Palette, and run the “Python: Select Interpreter” command, as shown in Figure 8.
Figure 8 Selecting the Python Interpreter
Then, select the recommended Python Interpreter, as shown in Figure 9.
Figure 9 Selecting the Python Interpreter
Finally, click on the “Run” icon in the Activity Bar. Click on the “create a launch.json file” link and in the popup menu that appears, select the Python environment, and then the “Python File – Debug the currently active Python file” option. Once the “launch.json” file is created (see below), save the file and close the corresponding tab.
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"justMyCode": true
}
]
}