Python in Visual Studio Code – August 2023 Release

Courtney Webster

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

This release includes the following announcements:

  • Python extension Dev Container for Contributors
  • Debug configuration for running Python files with arguments
  • Npm package for the Python extension API
  • Error-tolerant pytest discovery

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

Python extension Dev Container for Contributors

There is now a Dev Container in the source repo of the Python extension. Using this customized dev container, contributors can open the Python extension repository in GitHub Codespaces, and start working on developing and testing the Python extension with no other installation required. Since we’ve enabled pre-builds, the Dev Container will load instantly.

Python versions 3.7, 3.8, 3.9, 3.10, and 3.11 are pre-installed so you can readily switch between Python versions using pyenv. The dev container is also configured to install any required extensions for development, including Pylance and Black formatter extensions.

Debugger configuration for running files with arguments

The new Debugpy extension now provides a “Python File with Arguments” launch.json configuration, which is useful when you want to provide different input values for your Python file without the need to modify your code or the debugger configuration each time you run it.

To use this configuration, make sure you have the Debugpy extension installed. Then open the Run and Debug view by pressing Ctrl + Shift + D or ⌘ + ⇧ + D and click on either Create a launch.json file or the gear icon to access the launch.json file. Select Debugpy, and then select Python: File with Arguments from the available configurations.

Then, open the Python file that you want to debug, which requires command-line arguments. To start debugging, press F5, or Run > Start Debugging. A prompt will appear, allowing you to enter the desired arguments that should be passed to the Python file.

After entering your arguments, press Enter, and the debugger will start, letting you step through your code!

Theme: Catppuccin Macchiato (preview on vscode.dev)

Npm package for the Python extension API

The Python extension now provides an npm package to make it easier for other extension authors to access and track changes in the Python extension API. Check out the @vscode/python-extension npm module to work with Python environments available on your machine.

Error-tolerant pytest discovery

The Test Explorer panel now supports error-tolerant pytest discovery as a feature included in our new testing architecture. If pytest encounters a manageable error during discovery, such as an unknown import, all remaining tests will still be discovered outside the file containing the error. This feature is only available on the new testing rewrite behind an experimental feature. The rewrite is currently active for 100% of pre-release users and 25% of release users, but will be rolled out universally in the near future. In the meantime, you can continue to opt in or out of the rewrite with the pythonTestAdapter setting.

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:

  • Import resolution errors show more information about the environment in use (@pylance-release#4368).
  • Removal of the Create Environment button in dependency files will be rolled out to 100% of users based on feedback (@vscode-python#20982).
  • Run file in dedicated terminal re-added as a run configuration (@vscode-python#21282).

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:

Additionally, as a reminder, issues with the feature-request label require 7 👍 upvotes within 60 days of opening to issue to gauge community interest. We use this as another way to prioritize upcoming work.

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.

1 comment

Discussion is closed. Login to edit/delete existing comments.

  • Mohammed Kalimulla 1

    Error attempting to locate Jupyter: Running cells with ‘Python 3.11.0 64-bit’ requires notebook and jupyter package .

Feedback usabilla icon