Python in Visual Studio Code – October 2020 Release

Avatar

Luciana

We are pleased to announce that the October 2020 release of the Python Extension for Visual Studio Code is now available. You can download the Python extension from the Marketplace, or install it directly from the extension gallery in Visual Studio Code. If you already have the Python extension installed, you can also get the latest update by restarting Visual Studio Code. You can learn more about Python support in Visual Studio Code in the documentation.

This was a short release where we addressed 14 issues, and it includes debugpy 1.0!

If you’re interested, you can check the full list of improvements in our changelog.

Debugpy 1.0

We’re excited to announce that we’re releasing the 1.0 version of our debugger, debugpy, that was first announced in March this year.

Debugpy offers a great number of features that can help you understand bugs, errors and unexpected behaviors in your code. You can find an extensive list on our documentation, but check below for some of our favorite ones!

Debugging Web Apps

Debugpy supports live reload of web applications, such as Django and Flask apps, when debugging. This means that when you make edits to your application, you don’t need to restart the debugger to get them applied: the web server is automatically reloaded in the same debugging session once the changes are saved.  

To try it out, open a web application and add a debug configuration (by clicking on Run > Add Configuration…, or by opening the Run view and clicking on create launch.json file).  Then select the framework used in your web application – in this example, we selected Flask. 

Now you hit F5 to start debugging, and then just watch the application reload once you make a change and save it!

Live reload of Flask application when debugging

You can also debug Django and Flask HTML templates. Just set up breakpoints to the relevant lines in the HTML files and watch the magic happen:

Execution stopping on breakpoint in a template file

Debugging local processes

With the debugpy and the Python extension, you can get a list of processes running locally, and easily select one to attach debugpy to. Or, if you know the process ID, you can also add it directly to the “Attach using Process Id” configuration in the launch.json file:

Adding configuration for the debugger to attach to a local process

Attaching the debugger to a process running locally

Debugging remotely

Remote Development Extensions

You can use debugpy to debug your applications inside remote environments like Docker containers or remote machines (or even in WSL!) through the Remote Development extension. It allows VS Code to work seamlessly by running a light-weight server in the remote environment, while providing the same development experience as you get when developing locally:

Running the debugger inside a docker container

This way, you can use the same configurations for debugpy as you would locally – but it will actually be installed and executed in the remote scope. No more messing around with your local environment!

You can learn more about the VS Code Remote Development extensions on the documentation.

Remote attach

You can also configure the debugger to attach to a debugpy server running on a remote machine. All you need to provide is the host name and the port number the debugpy server is listening to in the remote environment:

Configuration for attaching the debugger to a remote machine

You can learn more about remote debugging in the documentation.

Other changes and enhancements

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

  • Fix exporting from the interactive window. (#14210)
  • Do not opt users out of the insiders program if they have a stable version installed. (#14090)

We’re constantly A/B testing new features. If you see something different that was not announced by the team, you may be part of the experiment! To see if you are part of an experiment, you can check the first lines in the Python extension output channel. If you wish to opt-out of A/B testing, you can open the user settings.json file (View > Command Palette… and run Preferences: Open Settings (JSON)) and set the “python.experiments.enabled” setting to false.

Be sure to download the Python extension for Visual Studio Code now to try out the above improvements. If you run into any problems or have suggestions, please file an issue on the Python VS Code GitHub page.

7 comments

Leave a comment