{"id":8420,"date":"2021-05-10T12:23:18","date_gmt":"2021-05-10T20:23:18","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/python\/?p=8420"},"modified":"2021-05-11T14:30:36","modified_gmt":"2021-05-11T22:30:36","slug":"python-in-visual-studio-code-may-2021-release","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/python\/python-in-visual-studio-code-may-2021-release\/","title":{"rendered":"Python in Visual Studio Code \u2013 May 2021 Release"},"content":{"rendered":"<p class=\"paragraph\" style=\"margin: 0in; text-align: justify; vertical-align: baseline;\"><span class=\"normaltextrun\"><span style=\"font-family: 'Segoe UI',sans-serif; color: #333333;\">We are pleased to announce that the May 2021 release of the Python Extension for Visual Studio Code is now available. You can <\/span><\/span><a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=ms-python.python\"><span class=\"normaltextrun\"><span style=\"font-family: 'Segoe UI',sans-serif; color: #0563c1;\">download the Python extension<\/span><\/span><\/a> <span class=\"normaltextrun\"><span style=\"font-family: 'Segoe UI',sans-serif; color: #333333;\">from the\u00a0Marketplace, or\u00a0install 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 \u00a0<\/span><\/span><a href=\"https:\/\/code.visualstudio.com\/docs\/python\/python-tutorial\"><span class=\"normaltextrun\"><span style=\"font-family: 'Segoe UI',sans-serif; color: #0563c1;\">Python support in Visual Studio Code<\/span><\/span><\/a> <span class=\"normaltextrun\"><span style=\"font-family: 'Segoe UI',sans-serif; color: #333333;\">in the documentation.\u00a0<\/span><\/span><span class=\"eop\"><span style=\"font-family: 'Segoe UI',sans-serif; color: #333333;\">\u00a0<\/span><\/span><\/p>\n<p>&nbsp;<\/p>\n<p class=\"paragraph\" style=\"margin: 0in; vertical-align: baseline;\">We\u2019re thrilled to announce that <a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=ms-python.vscode-pylance\">Pylance<\/a> 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.<\/p>\n<p>&nbsp;<\/p>\n<p class=\"paragraph\" style=\"margin: 0in; vertical-align: baseline;\"><span class=\"normaltextrun\"><span style=\"font-family: 'Segoe UI',sans-serif; color: #333333;\">If you\u2019re interested, check out the\u00a0full list of improvements in\u00a0our\u00a0<\/span><\/span><a href=\"https:\/\/github.com\/Microsoft\/vscode-python\/blob\/master\/CHANGELOG.md\"><span class=\"normaltextrun\"><span style=\"font-family: 'Segoe UI',sans-serif; color: #005da6;\">changelog<\/span><\/span><\/a><span class=\"normaltextrun\"><span style=\"font-family: 'Segoe UI',sans-serif; color: #333333;\">.<\/span><\/span><span class=\"eop\"><span style=\"font-family: 'Segoe UI',sans-serif; color: #333333;\">\u00a0<\/span><\/span><\/p>\n<p>&nbsp;<\/p>\n<h2>Upgraded language support, powered by Pylance<\/h2>\n<p>Today, we\u2019re excited to announce that the Python extension\u2019s 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&#8217;re unfamiliar with Pylance, you can read more about its awesome features in the <a href=\"https:\/\/devblogs.microsoft.com\/python\/announcing-pylance-fast-feature-rich-language-support-for-python-in-visual-studio-code\/\">preview release announcement blog post.<\/a><\/p>\n<p>If you\u2019ve been following along with our releases over the last year, we\u2019ve been making dramatic improvements to Python language support via the Pylance extension. As of this release, we\u2019ve included the Pylance extension as an optional dependency for the core Python extension. This means that you\u2019ll get the latest and greatest language support right out of the box with the Python extension (no separate install needed!).<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/05\/May2021-PylanceDependency.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-8421\" src=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/05\/May2021-PylanceDependency.png\" alt=\"Pylance as a dependency under the Python extension in the marketplace\" width=\"1531\" height=\"731\" srcset=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/05\/May2021-PylanceDependency.png 1531w, https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/05\/May2021-PylanceDependency-300x143.png 300w, https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/05\/May2021-PylanceDependency-1024x489.png 1024w, https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/05\/May2021-PylanceDependency-768x367.png 768w\" sizes=\"(max-width: 1531px) 100vw, 1531px\" \/><\/a><\/p>\n<p>We believe that Pylance provides the very best user experience for Python development and we hope that you\u2019ll try it out. However, we are committed to making sure that you can configure your development environment exactly how you like it.<\/p>\n<p>With this top of mind, our team has also been working to make language support better for everyone, regardless of your language server. We\u2019ve invested resources to standardize the way that language servers communicate with the Python extension (via <a href=\"https:\/\/microsoft.github.io\/language-server-protocol\/\">Language Server Protocol<\/a>). 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 <a href=\"https:\/\/github.com\/davidhalter\">David Halter<\/a>, <a href=\"https:\/\/github.com\/pappasam\/\">Samuel Roeca<\/a> and <a href=\"https:\/\/github.com\/danixeee\">danixeee<\/a> for their cooperation and partnership!). We are committed to maintaining open-source language support options for our users in the future.<\/p>\n<h3><strong>Configuring your language server<\/strong><\/h3>\n<p>If you\u2019d like to use another language server (e.g., Jedi), \u00a0you can uninstall or disable the Pylance extension at any point. Once you uninstall Pylance, it won&#8217;t be installed again when the Python extension updates.<\/p>\n<p>You can also change your language server explicitly via the settings UI or in your settings.json.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/05\/May2021-DisableUninstallLanguageServer.gif\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-8422\" src=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/05\/May2021-DisableUninstallLanguageServer.gif\" alt=\"Disabling and uninstalling Pylance, and changing the language server setting in VS Code.\" width=\"1333\" height=\"667\" \/><\/a><\/p>\n<h2>Faster extension startup time<\/h2>\n<p>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.<\/p>\n<p>This improvement has been showing 10% faster load times for Windows and macOS users, and 20% faster for Linux users! We\u2019ve also seen that it is decreasing the number of times the Python extension becomes unresponsive by 15% across the board.<\/p>\n<p>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!<\/p>\n<p>With this update, we also included a refresh button on the topwhen you run the \u201c<strong>Python: Select Interpreter<\/strong>\u201d command. This way you can make sure the list you are looking at is up to date:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/05\/May2021-refresh.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-8423\" src=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/05\/May2021-refresh.png\" alt=\"New refresh button at the top of the Python interpreters list.\" width=\"624\" height=\"303\" srcset=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/05\/May2021-refresh.png 624w, https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/05\/May2021-refresh-300x146.png 300w\" sizes=\"(max-width: 624px) 100vw, 624px\" \/><\/a><\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/python\/python-in-visual-studio-code-april-2021-release\/\">On our last release<\/a>, 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!<\/p>\n<h2>New debugger feature: live reload for Python scripts<\/h2>\n<p>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!<\/p>\n<p>Our debugger has support for Django and Flask auto-reload <a href=\"https:\/\/devblogs.microsoft.com\/python\/python-in-visual-studio-code-april-2020-release\/\">for over a year now<\/a>. We\u2019re excited to bring support for code reload of Python scripts as well!<\/p>\n<p>With this change, \u00a0your changes will be applied after the debugger has already started executing and has hit a breakpoint, without the need to restart the debugger:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/05\/May2021-CodeReload.gif\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-8424\" src=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/05\/May2021-CodeReload.gif\" alt=\"Automatic code reloading with the Python debugger in VS Code.\" width=\"1724\" height=\"1130\" \/><\/a><\/p>\n<p class=\"paragraph\" style=\"margin: 0in; vertical-align: baseline;\"><span style=\"font-family: 'Segoe UI',sans-serif;\">If you want to try it out, you can add the following line to your debug configuration in the .vscode\/launch.json file:<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/05\/May2021-AutoReloadConfig.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-8425\" src=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/05\/May2021-AutoReloadConfig.png\" alt=\"Configuration to enable auto reload in the launch.json file(&quot;autoReload&quot;: {&quot;enable&quot; : true})\" width=\"542\" height=\"302\" srcset=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/05\/May2021-AutoReloadConfig.png 542w, https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/05\/May2021-AutoReloadConfig-300x167.png 300w\" sizes=\"(max-width: 542px) 100vw, 542px\" \/><\/a><\/p>\n<p class=\"paragraph\" style=\"margin: 0in;\"><span style=\"font-family: 'Segoe UI',sans-serif;\">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 <\/span>if __name__ == \u201c__main__\u201d <span style=\"font-family: 'Segoe UI',sans-serif;\">checks, like in the example below:<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/05\/May2021-IfNameEqualsMainCodeExcerpt.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-8426\" src=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/05\/May2021-IfNameEqualsMainCodeExcerpt.png\" alt=\"Python code with function call under a if __name__ == &quot;__main__&quot; condition.\" width=\"624\" height=\"302\" srcset=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/05\/May2021-IfNameEqualsMainCodeExcerpt.png 624w, https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2021\/05\/May2021-IfNameEqualsMainCodeExcerpt-300x145.png 300w\" sizes=\"(max-width: 624px) 100vw, 624px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<h2>Other changes and enhancements<\/h2>\n<p>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:<\/p>\n<ul>\n<li>Add a &#8220;Default&#8221; language server option, which dynamically chooses which language server to use. (<a href=\"https:\/\/github.com\/Microsoft\/vscode-python\/issues\/16157\">#16157<\/a>)<\/li>\n<li>Automatically indent following `match` and `case` statements. (<a href=\"https:\/\/github.com\/microsoft\/vscode-python\/issues\/16100\">#16100<\/a>) (thanks <a href=\"https:\/\/github.com\/cdce8p\">Marc Mueller<\/a>!)<\/li>\n<li>Add Python: Refresh TensorBoard command (<a href=\"https:\/\/github.com\/microsoft\/vscode-python\/issues\/16053\">#16053<\/a>)<\/li>\n<li>Added compatability with pypy3.7 interpreter. (thanks\u00a0<a href=\"https:\/\/github.com\/olliemath\">Oliver Margetts<\/a>!) (<a href=\"https:\/\/github.com\/Microsoft\/vscode-python\/issues\/15968\">#15968<\/a>)<\/li>\n<\/ul>\n<p class=\"paragraph\" style=\"margin: 0in; vertical-align: baseline;\"><span class=\"normaltextrun\"><span style=\"font-family: 'Segoe UI',sans-serif; color: #333333;\">Be sure to <\/span><\/span><a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=ms-python.python\" target=\"_blank\" rel=\"noopener\"><span class=\"normaltextrun\"><span style=\"font-family: 'Segoe UI',sans-serif; color: #337ab7;\">download the Python extension<\/span><\/span><\/a> <span class=\"normaltextrun\"><span style=\"font-family: 'Segoe UI',sans-serif; color: black;\">for Visual Studio Code now to try out the above improvements. If you run into any problems or have suggestions, <a href=\"https:\/\/github.com\/microsoft\/vscode-python\/issues\/new\/choose\">please file an issue<\/a> <\/span><\/span><span class=\"normaltextrun\"><span style=\"font-family: 'Segoe UI',sans-serif; color: black;\">on the <a href=\"https:\/\/github.com\/Microsoft\/vscode-python\">Python VS Code GitHub page<\/a>.<\/span><\/span><span class=\"eop\"><span style=\"font-family: 'Segoe UI',sans-serif; color: black;\">\u00a0<\/span><\/span><\/p>\n<p class=\"paragraph\" style=\"margin: 0in; vertical-align: baseline;\"><span class=\"eop\"><span style=\"font-family: 'Segoe UI',sans-serif; color: black;\">\u00a0<\/span><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>We\u2019re thrilled to announce that the May 2021 release of the Python extension is here and it brings Pylance as the new default language server for Python, faster extension startup times and code reload when debugging Python scripts. Keep on reading to learn more! <\/p>\n","protected":false},"author":33429,"featured_media":8424,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1,6],"tags":[],"class_list":["post-8420","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","category-visual-studio-code"],"acf":[],"blog_post_summary":"<p>We\u2019re thrilled to announce that the May 2021 release of the Python extension is here and it brings Pylance as the new default language server for Python, faster extension startup times and code reload when debugging Python scripts. Keep on reading to learn more! <\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/posts\/8420","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/users\/33429"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/comments?post=8420"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/posts\/8420\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/media\/8424"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/media?parent=8420"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/categories?post=8420"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/tags?post=8420"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}