Python in Visual Studio Code – September 2023 Release

Courtney Webster

We’re excited to announce the September 2023 release of the Python and Jupyter extensions for Visual Studio Code!

This release includes the following announcements:

  • “Recreate” or “Use Existing” options added to the Python: Create Environment command
  • Experimental terminal activation using environment variables
  • Community-contributed yapf extension

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

“Recreate” or “Use Existing” options when using Python: Create Environment with existing .venv

When working within a workspace that already contains a .venv folder, the Python: Create Environment command has been updated to provide you with options to either recreate or use the existing environment. If you opt-in to recreate the environment, your current .venv will be deleted, allowing you to recreate a new environment named .venv. You can customize this new environment by following the Python: Create Environment flow, selecting your preferred interpreter, and specifying any dependency files for installation. In the case the environment cannot be deleted, for example, due to it being active, you will be prompted to delete the environment manually.

Alternatively, if you opt to use the existing environment, the environment will be selected for your workspace.

Gif demonstrating "recreate" and "use existing" commands with Create Environment

Experimental terminal activation using environment variables

This month, we are beginning the rollout of terminal activation using environment variables that activate the selected environment in the terminal without requiring any activation commands. With this new experience, the Python extension uses environment variables to activate terminals, which is done implicitly on terminal launch, resulting in a faster experience, particularly for conda users. This experiment will serve as the default experience for 25% of Pre-release users behind the experimental ["pythonTerminalEnvVarActivation"] flag. You can opt into or out of this experiment in your User settings by modifying "python.experiments.optInto" or "python.experiments.optOutFrom" respectively in your settings.json. If you have any comments or suggestions regarding this experience, please share them in vscode-python#11039.

Gif demonstrating terminal auto activation.

Community-contributed yapf extension

There is now a community-contributed (@EeyoreLee) yapf formatter extension available! This extension provides yapf formatting support for Python files and Notebook cells. Yapf support built into the Python extension will be deprecated in favor of the extension support. Subsequently, the corresponding setting python.formatting.yapf will be removed from the Python extension.

This corresponds to the work announced in April 2022 to break out the tools support we offer in the Python extension for Visual Studio Code into separate extensions, with the intent of improving performance, and stability and no longer requiring the tools to be installed in a Python environment – as they can be shipped alongside an extension.

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:

  • Unresolved import errors now indicate in which environment Pylance is looking for packages (pylance-release#4368)
  • There’s a new experimental setting called python.analysis.enableSyncServer that enables multi-file IntelliSense support in Support for and virtual workspaces is coming soon!
  • Pylance no longer crashes on Jupyter Notebook cell deletion (@pylance-release#4685)
  • There is a new dedicated topic on Python formatting in our docs where you’ll learn how to set a default formatter such as autopep8 or Black formatter and customize it through various settings.

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

Call for Community Feedback

As we are planning and prioritizing future work, we value your feedback! Below are a few issues we would love feedback on:

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.


Discussion is closed.

Feedback usabilla icon