Python on Visual Studio Code

Python is fully supported in Visual Studio Code through extensions. Popular extensions in the Marketplace provide code completion, linting, debugging, code formatting, snippets, and more.

Download VS Code - If you haven’t downloaded VS Code yet, quickly install for your platform (Windows, Mac, Linux).

Install Python Extension

VS Code is a fast editor and ships with only the basic features. Add Python language support to VS Code by installing one of the popular Python extensions.

  1. Select an extension.
  2. Install the extension by typing ext install into the Command Palette ⇧⌘P (Windows, Linux Ctrl+Shift+P).

Tip: The extensions shown above are dynamically queried. Click on an extension tile above to read the description and reviews to decide which extension is best for you. See more in the Marketplace.

The examples in this document will use Don Jayamanne’s popular and full featured Python Extension.

Code Completion

Python extensions support code completion and Intellisense. Intellisense is a general term for a number of features, including intelligent code completion (in-context method and variable suggestions) across all your files and for built-in and thirty-party modules.

Quickly see methods, class members, and documentation.

Tip: Trigger code completion with ⌃Space (Windows, Linux Ctrl+Space).

Linting

Linting is the analysis of your Python code for potential errors. Use Visual Studio Code to quickly navigate to the errors and warnings in your code.

Tip: Don Jayamanne’s Python extension gives you the option of using three different linters - Pylint, Pep8, and Flake8. See the wiki for more details.

Debugging

No more print statement debugging! Set breakpoints, inspect data, and use the debug console. Debug a number of different type of Python applications, including multi-threaded, web, and remote applications.

Tip: Follow the instructions in the wiki for getting started with debugging, including setting up your launch.json debugging configuration and troubleshooting common issues.

Tip: Read more about general information about debugging in Visual Studio Code in the debugging document.

Snippets

Snippets will take productivity to the next level. You can configure your own snippets and use snippets provided by an extension.

Tip: Snippets appear in the same way as code completion ⌃Space (Windows, Linux Ctrl+Space).

Configuration

You will need an extension and Python installed. Other dependencies are optional and depend on the features you want to use. Read through the requirements on the extension’s README.

Next Steps

Common Questions

Q: Why won’t linting work for me?

A: First make sure you have installed an extension. Next, many extensions have a dependency on an external package. Install the required packages using a Python package manager like pip or easy_install. You can read more about troubleshooting linting issues here.