Python in Visual Studio Code – May 2023 Release

Courtney Webster

We’re excited to announce that the May 2023 release of the Python and Jupyter extensions for Visual Studio Code are now available!

This release includes the following announcements:

  • Jupyter extension no longer installed by default
  • Microvenv support for Create Environment command
  • Automatic conversion of f-strings with Pylance
  • Code navigation enabled on strings that contain module names

If you’re interested, you can check the full list of improvements in our changelogs for the Python, Jupyter and Pylance extensions.

Microvenv support for Create Environment command

When the Python: Create environment command is invoked using a Python distribution that doesn’t have the venv package installed, the Python extension now uses microvenv as a fallback. This can be a hurdle for Python environments that are pre-installed on Unix-based systems, which causes the Python: Create Environment command to fail.

Microvenv is a lightweight Python module that offers a minimalist approach to creating virtual environments for your Python projects. It is not equipped with traditional activation scripts like virtual environments, but it provides a good alternative for creating an isolated environment when the venv module is not available in your Python distribution.

The Python: Create Environment command will also install pip into the environments created via microvenv.

Jupyter extension no longer installed by default

The Jupyter extension is no longer automatically installed alongside the Python extension by default. This change was made in response to feedback from Dev Containers users who wanted a faster container creation process.

If you have Dev Container definitions that only list the Python extension and wish to continue using the Jupyter notebooks features in your containers, you can add the Jupyter extension ID to your devcontainer.json file:

  "customizations": {
    "vscode": {
      "extensions": ["ms-python.vscode-pylance", "ms-python.python", "ms-toolsai.jupyter"]

Alternatively, you can create a Profile that includes the Python and Jupyter extensions, as well as any other of your favorite extensions.

Automatic conversion of f-strings with Pylance

There’s a new "python.analysis.autoFormatStrings" setting that enables automatic conversion of strings to f-strings when using Pylance. Once enabled, Pylance will automatically insert an f at the beginning of a string when you insert { within quotes.

This setting is currently disabled by default, but it is expected to be enabled in the upcoming release pending positive feedback. If you have any comments or suggestions regarding this feature, please feel free to share them on the Pylance GitHub repository.

Code navigation enabled on strings that contain module names

There’s another new experimental setting called "python.analysis.gotoDefinitionInStringLiteral" that enables Go to Definition from module-like string literals. This can be particularly helpful if you’re working on web applications, such as Django apps, and want to navigate to modules defined in string literals.

This new setting, like the autoFormatStrings setting mentioned earlier, is currently disabled by default. However, we plan to enable this behavior by default in the next release based on feedback. Eventually, we plan to remove this setting entirely.

Other Changes and Enhancements

We have also added small enhancements and fixed issues requested by users that should improve your experience working with Python and Jupyter Notebooks in Visual Studio Code. Some notable changes include:

  • Run Python actions are now in sub-menus (vscode-python#14350)
  • Black formatter and Autopep8 extension recommendations

We would also like to extend special thanks to this month’s contributors:

Try out these new improvements by downloading the Python extension and the Jupyter extension from the Marketplace, or install them directly from the extensions view in Visual Studio Code (Ctrl + Shift + X or ⌘ + ⇧ + X). You can learn more about Python support in Visual Studio Code in the documentation. If you run into any problems or have suggestions, please file an issue on the Python VS Code GitHub page.