How to configure Visual Code for Python on Windows

This post explains how to configure Python for Visual Code on Windows.

Step-by-step Instructions

1. Install Python

Go to Python website and download it.

2. Install Visual Code

Go to Visual Code website and download it.

3. Install Visual Code extension for another Language

Visual Code is installed by default in English. If this is the language you want to use, you do not need to do anything else.

In case you want to use a display language different to English, you need to install it as an extension.

In the main Visual Code window, find the “Extension” icon on the left, that looks like four squares.

In the search box, type your language. For example, if you want to install it in English, you need to install the extension “Spanish Language Pack for Visual Studio Code”. Once the package is opened, click on “Install”.

A pop-up will appear on the bottom right corner. Click on “Change Language and Restart”.

4. Install Python extension for Visual Code

In the main Visual Code window, find the “Extension” icon on the left, that looks like four squares.

Among the available extensions, search for Python by Microsoft and click on “Install”.

5. Set the Line Length Indicator

Go to Code > Preferences > Settings. Enter rulers. Click the link labeled “Edit in settings.json”.

Add the following to the editor.rulers settings:

"editors.rulers": [
80, 120
]

You can leave the second value blank.

6. (optional) Simplify Output Terminal

You can simplify the output terminal.

Open a folder where there is a Python project. Click on the “Run/Debug” icon (a triangle with a bug) on the left side of the screen.

Click on “Create a launch.json File”. A launch.json files adds a configuration for a project.

Select Python options in the prompto that appear.

Make the following change:

{
    --snip--
    "configuration": [
        --snip--
        "console": "internalConsole"
        "justMyCode": true
    ]
}

Value “internalConsole” simplifies the output, removing the commands that are being used to run the file.

You can revert whenever you want to the default value “integratedTerminal”.

External References

Leave a Reply

Your email address will not be published. Required fields are marked *