Python in Visual Studio Code – April 2020 Release

Jeffrey Mew

Jeffrey

We are pleased to announce that the April 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 43 issues, including ipywidgets support  in Jypyter Notebooks and debugger support for Django and Flask auto-reload. You can check the full list of improvements iour changelog. 

ipywidgets Support in Jupyter Notebooks 

ipywidgets support has been one of our top requested features on GitHub since the release of Jupyter Notebook support in the Python Extension. Today we’re excited to announce that we now support all ipywidgets (including custom ones) in Jupyter Notebooks in VS Code. This means that you can bring all your favorite interactive plotting libraries such as beakerXbqplotand many more, to visualize and interact with data in Notebooks and VS Code! 

ipywidgets support in Jupyter Notebooks editor

Debugger support for Django and Flask autoreload  

In the March release of the Python extension, we introduced our new Python debugger, debugpy. We’re happy to announce that it supports live reloading of web applications, such as Django and FlaskNow when you make edits to your application, you don’t need to restart the debugger to get them applied anymore. 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 Django. 

Debugger Configuration Options in Visual Studio Code

This will create a launch.json file and add a run/debug configuration to it. To get live reloading working, simply remove the “–no-reload” flag in the args property:

Django configuration on launch.json file with reload functionality disabled

This configuration will now look like this: 

      {
            "name": "Python: Django",
            "type": "python",
            "request": "launch",
            "program": "${workspaceFolder}\\manage.py",
            "args": [
                "runserver",
            ],
            "django": true
        },

Now when you start debugging (F5)make changes to the application and save them, the server will automatically reload.

Image April2020 autoreload Small



Pro tip: To enable live reload for Flask applications, set “FLASK_DEBUG”: “1” in the launch.json file, as it’s set to “0” by default.    



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: 

  • Ensure plot fits within the page of the PDF. (#9403) 
  • Support using ‘esc’ or ‘ctrl+u’ to clear the contents of the interactive window input box. (#10198) 
  • Experiments no longer block on telemetry. (#10008) 
  • Ensure user code in cell is preserved between cell execution and cell edits. (#10949) 

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, please file an issue on the Python VS Code GitHub page. 

 

1 comment

Comments are closed. Login to edit/delete your existing comments