Python in Visual Studio Code – May 2021 Release
We are pleased to announce that the May 2021 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.
We’re thrilled to announce that Pylance is now the default language server for Python and is bundled with the core Python extension as an optional extension starting with this release. Other notable updates are that we now have faster extension startup time and a new debugger feature: live reload for Python scripts.
If you’re interested, check out the full list of improvements in our changelog.
Upgraded language support, powered by Pylance
Today, we’re excited to announce that the Python extension’s default language support is now powered by Pylance. This upgrade provides what we believe is the most performant and user-friendly Python editing experience for Visual Studio Code ever. If you’re unfamiliar with Pylance, you can read more about its awesome features in the preview release announcement blog post.
If you’ve been following along with our releases over the last year, we’ve been making dramatic improvements to Python language support via the Pylance extension. As of this release, we’ve included the Pylance extension as an optional dependency for the core Python extension. This means that you’ll get the latest and greatest language support right out of the box with the Python extension (no separate install needed!).
We believe that Pylance provides the very best user experience for Python development and we hope that you’ll try it out. However, we are committed to making sure that you can configure your development environment exactly how you like it.
With this top of mind, our team has also been working to make language support better for everyone, regardless of your language server. We’ve invested resources to standardize the way that language servers communicate with the Python extension (via Language Server Protocol). This work has enabled us to further improve the performance and overall experience of other language servers, like the open-source Jedi language server (thanks to David Halter, Samuel Roeca and danixeee for their cooperation and partnership!). We are committed to maintaining open-source language support options for our users in the future.
Configuring your language server
If you’d like to use another language server (e.g., Jedi), you can uninstall or disable the Pylance extension at any point. Once you uninstall Pylance, it won’t be installed again when the Python extension updates.
You can also change your language server explicitly via the settings UI or in your settings.json.
Faster extension startup time
Our team has been working hard on improving stability and performance of the Python extension, and we are now thrilled to announce that starting in this release, the Python extension will be loading much faster and more reliably thanks to a major improvement on our Python environments discovery mechanism.
This improvement has been showing 10% faster load times for Windows and macOS users, and 20% faster for Linux users! We’ve also seen that it is decreasing the number of times the Python extension becomes unresponsive by 15% across the board.
If you used to have issues with the Python extension not loading when on a machine with many Python environments, try this newest version and let us know how it works for you!
With this update, we also included a refresh button on the topwhen you run the “Python: Select Interpreter” command. This way you can make sure the list you are looking at is up to date:
On our last release, we had also announced a preview of Poetry support with the Python extension. With this improvement, Poetry support is now available on the stable version of the Python extension as well!
New debugger feature: live reload for Python scripts
Debugging with the Python extension has gotten even better! If you ever made changes to your code after the debugger execution has hit a breakpoint, and you wished those changes were applied without the need of reloading the debugger, this update is for you!
Our debugger has support for Django and Flask auto-reload for over a year now. We’re excited to bring support for code reload of Python scripts as well!
With this change, your changes will be applied after the debugger has already started executing and has hit a breakpoint, without the need to restart the debugger:
If you want to try it out, you can add the following line to your debug configuration in the .vscode/launch.json file:
Note that when the debugger performs a reload, code that runs on import may be executed again. To avoid things happening twice, try and only use imports, constants, and definitions in your module, and put all code into functions or if __name__ == “__main__” checks, like in the example below:
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:
- Add a “Default” language server option, which dynamically chooses which language server to use. (#16157)
- Automatically indent following `match` and `case` statements. (#16100) (thanks Marc Mueller!)
- Add Python: Refresh TensorBoard command (#16053)
- Added compatability with pypy3.7 interpreter. (thanks Oliver Margetts!) (#15968)
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.
If I uninstalled Pylance once after the update, will I ever have to uninstall it ever *again* everytime the extension updates? Or do we need an adblock for vscode?
Thanks for asking this question! Pylance should not be installed again once you uninstall it and the Python extension updates. We updated the blog post to clarify that 😊
I want to know: How to run on Android and iPhone?
For example print(”’input input: h, display display: a yī/one, also called: a horizontal, input method: h. a yī/one, also called: a horizontal héng, input method: h.”’ )
I hope that python programming can also have its own input method, so that simple mathematical knowledge can be used for programming, especially for people in the arts and sciences to learn python programming. Let people who are engaged in studying python python programming also learn Chinese characters.
Thank you very much! 非常感谢!
When will this be available in Visual Studio 2019? Do we have to wait for Visual Studio 2022? I still prefer using Visual Studio to Visual Studio Code for Python development.
I think it’s more convenient to Develop Python with Visual Studio Code.😂
Very good news team. Actually I work every day with python and I find vscode very useful, it is really great, although sometimes I have come across some bugs that I have to eat because I use it even though the recommendation of the teachers is to use the jupyter browser. but I prefer vscode a thousand times. Congratulations.
I read your article, thanks for sharing this information.