Before configuring Visual Studio Code, Python must be present on your system. Usually Python is included by default in Linux distributions. In Windows, you have to install it by yourself. If you haven’t installed it yet, follow the steps described here.

If you have successfully installed Python, open Visual Studio Code, and choose the theme you want (Figure 1). Then, click on the “Mark Done” button.

Figure 1 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”, click on the “Install” button (as shown in Figure 2) and wait for the installation to complete. It is advisable to install the Python extension that is developed by Microsoft.

Figure 2 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 3.

Figure 3 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 4.

Figure 4 Selecting the Python Interpreter

Then, select the recommended Python Interpreter, as shown in Figure 5.

Figure 5 Selecting the Python Interpreter

Finally, from the main menu select “Run → Add Configuration…”, click on the “Python Debugger” and then, “Python File Debug the currently open Python file”, as shown in Figure 6.

Figure 6 Selecting the Debug Configuration

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"
        }
    ]
}

Visual Studio Code has been configured properly! Now it’s time to conquer the world of Python!