Top 10 Python Extensions for Visual Studio Code

Daniel Morales
Oct 09, 2021

Top 10 Python Extensions for Visual Studio Code

Oct 09, 2021 7 minutes read

In this new post we want to talk about the most useful Python extensions for Visual Studio Code. 

Visual Studio Code is an integrated development environment created by Microsoft for Windows, Linux and macOS. Among its features are debugging, syntax highlighting, smart code completion, snippets, code refactoring and integrated Git. Users can change the theme, keyboard shortcuts, preferences and install extensions that add additional functionality.

Precisely we are going to talk about the extensions you can install for VS. Here is a list of our favorites


1- Python




Python extension for Visual Studio Code

A Visual Studio Code extension with rich support for the Python language (for all actively supported versions of the language: >=3.6), including features such as IntelliSense (Pylance), linting, debugging, code navigation, code formatting, refactoring, variable explorer, test explorer, and more!

NOTE: Web support -- e.g., github.dev -- is limited.

Installed extensions
The Python extension will automatically install the Pylance and Jupyter extensions to give you the best experience when working with Python files and Jupyter notebooks. However, Pylance is an optional dependency, which means that the Python extension will remain fully functional if it is not installed. You can also uninstall it at the expense of some features if you are using a different language server.

2- Python Indent




It is used to correct Python indentation in Visual Studio Code.

How it works
Every time you press the Enter key in a Python context, this extension will parse your Python file down to the location of your cursor, and determine exactly how much to indent the next line (or two in the case of hanging indents) and how much to indent nearby lines.

There are three main cases when determining the correct indent. Review the documentation here: https://github.com/kbrose/vsc-python-indent

3- Python Doctring Generator



Visual Studio Code extension to quickly generate docstrings for python functions.

Features
  • Quickly generate a docstring fragment that can be tabbed.
  • Choose from several types of docstring formats.
  • Infer parameter types via pep484 type hints, default values and var names.
  • Support for args, kwargs, decorators, errors and parameter types.

Docstring Formats
  • Google (default)
  • docBlockr
  • Numpy
  • Sphinx
  • PEP0257 (coming soon)

Usage
  • The cursor must be on the line directly below the definition to generate a complete auto-populated docstring.
  • Press enter after opening the docstring with triple quotes ("""" or ''')
  • Keyboard shortcut: ctrl+shift+2 or cmd+shift+2 for mac
  • Can be changed in Preferences -> Keyboard shortcuts -> extension.generateDocstring
  • Command: Generate Docstring
  • Right-click menu: Generate Docstring


4- Python Extended





Python Extended is a vscode snippet that makes it easy to write Python code by providing completion options along with all arguments.

Usage
Run vscode and in a python file, type the name of the method to complete and press tab or enter on selection.

How to install
Open vscode. Press F1, search for "ext install" followed by the extension name, in this case "ext install Python Extended" without the ">". Or if you prefer ">ext install", press enter, search for "Python Extended".



5- Python Preview





A Visual Studio Code extension with debug preview support for the Python language.

Requirements
  • Install a version of Python 3.6 or Python 2.7. Make sure that the location of your Python interpreter is included in your PATH environment variable.
  • It is best to install the Python extension for Python Intellisense.


6- AREPL for Python




AREPL automatically evaluates Python code in real time as you type.

Usage
  • First, make sure you have python 3.7 or higher installed.
  • Open a python file and click on the cat in the top right bar to open AREPL. You can click the cat again to close it.
  • Or run AREPL via the search command: control-shift-p
  • or use the shortcuts: control-shift-a (current document) / control-shift-q (new document)

Features
  • Real-time evaluation: no need to run - AREPL evaluates your code automatically. You can control this (or even disable it) in the settings.
  • Variable display: The final state of your local variables is displayed in a collapsible JSON format.
  • Error display: The moment you make a mistake an error is displayed with the stack trace.
  • Settings: AREPL offers many settings to suit your user experience. Customize the look and feel, bounce time, python options and much more.

7- Python Path




This extension adds a set of tools to help generate internal import statements in a Python project.

Features
  • "Copy Python Path" is accessible from:
  • Command line
  • Explorer context menu
  • Editor context menu
  • Editor title context menu


8- Python Test Explorer




This extension allows you to run your Python Unittest, Pytest or Testplan tests with the Test Explorer user interface.

How to get started
  • Install the extension
  • Configure Visual Studio Code to discover your tests (see the Configuration section and the documentation for the test framework of your choice:
  • Unittest documentation
  • Pytest documentation
  • Testplan documentation
  • Open the sidebar of the test view
  • Execute your tests via the Run icon in the Test Explorer

Features
  • Displays a Test Explorer in the test view in the VS Code sidebar with all detected tests and suites and their status
  • Convenient error reporting during test detection
  • Unittest, Pytest and Testplan debugging
  • Displays the log of a failed test when the test is selected in the explorer
  • Test rerun when saving tests
  • Supports multi-root workspaces
  • Supports Unittest, Pytest and Testplan test frameworks and their plugins

9- Python Snippets




A snippet package to make working with Python more productive This snippet package contains all of the following Python methods
  • all built-in python snippets and contains at least one example for each method
  • all python string snippets contain at least one example for each method
  • all python list snippets contain at least one example for each method
  • all Python set snippets contain at least one example for each method
  • all Python tuple snippets contain at least one example for each method
  • all python dictionary snippets contain at least one example for each method
  • And it contains many other code snippets (such as if/else, for, while, while/else, try/catch, file process, and
  • class snippets and class examples for oop (polymorphism, encapsulation, inheritance, etc.).

If you don't use a method don't worry this extension contains a lot of code examples for each python method.

This extension is not just a code snippet, it will also be useful for learning the python programming language.

You will learn all python methods with a lot of code examples.
For example, if you want to use the string replacement method, you just need to use .replace.

But if you don't know how to use the replace method then use string.replace =>

10- Jupyter




A Visual Studio Code extension that provides basic notebook support for language kernels that are compatible with Jupyter Notebooks today. Many language kernels will work without any modifications. To enable advanced features, modifications to the VS Code language extensions may be necessary.

Notebook support
The Jupyter Extension uses VS code's built-in notebook support. This interface offers a number of advantages to notebook users:

  • Out-of-the-box support for VS Code's wide range of basic code editing functions, such as hot output, search and replace, and code folding.
  • Editor extensions such as VIM, bracket coloring, linters and many more are available while editing a cell.
  • Deep integration with the general workbench and file-based features of VS Code, such as outline view (table of contents), breadcrumbs, and other operations.
  • Fast load times for Jupyter notebook (.ipynb) files. Any notebook file is loaded and rendered as quickly as possible, while execution-related operations are initialized behind the scenes.
  • Includes a notebook diff tool, which makes it easy to compare and visualize differences between code cells, results and metadata.
  • Extensibility beyond what the Jupyter extension provides. Extensions can now add their own specific language or runtime to notebooks, such as the .NET and Gather interactive notebooks.
  • Although the Jupyter extension comes with a comprehensive set of the most commonly used renderers for output, the marketplace supports installable custom renderers to make working with your notebooks even more productive. To get started writing your own, check out the VS Code renderer api documentation.

Conclusion


There are many extensions that you can use with your Visual Studio Code, and deciding which one to use will involve testing, reviewing utilities, use cases and so on in order to make your work easier while coding!

Also read: Why Decorators In Python Are Pure Genius?
Join our private community in Discord

Keep up to date by participating in our global community of data scientists and AI enthusiasts. We discuss the latest developments in data science competitions, new techniques for solving complex challenges, AI and machine learning models, and much more!