{"id":6875,"date":"2018-11-08T10:00:16","date_gmt":"2018-11-08T17:00:16","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/python\/?p=6875"},"modified":"2019-02-17T15:26:55","modified_gmt":"2019-02-17T22:26:55","slug":"python-in-visual-studio-code-october-2018-release","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/python\/python-in-visual-studio-code-october-2018-release\/","title":{"rendered":"Python in Visual Studio Code \u2013 October 2018 Release"},"content":{"rendered":"<p>We are pleased to announce that the October 2018 release of the Python Extension for Visual Studio Code is now available. You can\u00a0<u><a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=ms-python.python\">download the Python extension<\/a><\/u>\u00a0from the Marketplace, or install it directly from the extension gallery in Visual Studio Code. You can learn more about\u00a0<u><a href=\"https:\/\/code.visualstudio.com\/docs\/languages\/python\">Python support in Visual Studio Code<\/a><\/u>\u00a0in the documentation.<\/p>\n<p>In this release we have closed a total of 49 issues, including:<\/p>\n<ul>\n<li>Jupyter support: import notebooks and run code cells in a Python Interactive window<\/li>\n<li>Use new virtual environments without having to restart Visual Studio Code<\/li>\n<li>Code completions in the debug console window<\/li>\n<li>Improved completions in language server, including recognition of namedtuple, and generic types<\/li>\n<\/ul>\n<p>Keep on reading to learn more!<\/p>\n<h2>Jupyter Support with the Python Interactive window<\/h2>\n<p>The extension now contains new editor-centric interactive programming capabilities built on top of Jupyter. To get started, make sure to have Jupyter installed in your environment (e.g.\u00a0<a href=\"https:\/\/code.visualstudio.com\/docs\/python\/environments#_select-an-environment\">set your environment<\/a>\u00a0to Anaconda) and type\u00a0<strong>#%%<\/strong>\u00a0into a Python file to define a Cell. You will notice a \u201cRun Cell\u201d code lens will appear above the\u00a0<strong>#%%<\/strong>\u00a0line:<\/p>\n<p><img decoding=\"async\" class=\"wp-image-6883 size-full aligncenter\" src=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2018\/11\/1_AddCell.png\" alt=\"You can define code cells by adding #%%, click Run Cell to run them. Here we run a cell that prints &quot;Hello world&quot;.\" width=\"959\" height=\"131\" srcset=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2018\/11\/1_AddCell.png 959w, https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2018\/11\/1_AddCell-300x41.png 300w, https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2018\/11\/1_AddCell-768x105.png 768w\" sizes=\"(max-width: 959px) 100vw, 959px\" \/><\/p>\n<p>Clicking Run Cell will open the Python Interactive window to the right and run your code. You can define further cells or press Shift+Enter to run the current cell and automatically create a new one (or advance to the next cell).<\/p>\n<p>Separately, if you were to open a Jupyter Notebook file (.ipynb), you will now be prompted to import the notebook as Python code:<\/p>\n<p><img decoding=\"async\" class=\"wp-image-6885 size-full aligncenter\" src=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2018\/11\/2_ImportNotebook.png\" alt=\"A prompt appears to import Jupyter notebooks when you open an .ipynb file\" width=\"556\" height=\"115\" srcset=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2018\/11\/2_ImportNotebook.png 556w, https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2018\/11\/2_ImportNotebook-300x62.png 300w\" sizes=\"(max-width: 556px) 100vw, 556px\" \/><\/p>\n<p>Cells in the Jupyter Notebook will be converted to cells in a Python file by adding #%% lines. You can run the cells to view the notebook output in Visual Studio code, including plots:<\/p>\n<p><img decoding=\"async\" class=\"wp-image-6886 size-full aligncenter\" src=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2018\/11\/3_RunNotebook.png\" alt=\"Plots are supported, on the left is a plot call and on the right we see the plot displayed in dark theme\" width=\"1115\" height=\"652\" srcset=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2018\/11\/3_RunNotebook.png 1115w, https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2018\/11\/3_RunNotebook-300x175.png 300w, https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2018\/11\/3_RunNotebook-768x449.png 768w, https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2018\/11\/3_RunNotebook-1024x599.png 1024w\" sizes=\"(max-width: 1115px) 100vw, 1115px\" \/><\/p>\n<p>Check out our blog post\u00a0<a href=\"https:\/\/devblogs.microsoft.com\/python\/2018\/11\/08\/data-science-with-python-in-visual-studio-code\/\">Data Science with Python in Visual Studio Code<\/a>\u00a0for a deep dive of the new capabilities!<\/p>\n<h2>Completions in the Debug Console<\/h2>\n<p>When stopped at a breakpoint and typing expressions into the debug console, you now get completions appearing:<\/p>\n<p><img decoding=\"async\" class=\"aligncenter wp-image-6887 size-full\" src=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2018\/11\/4_DebugConsole.png\" alt=\"Completions are shown when typing expressions into the Debug Console\" width=\"692\" height=\"245\" srcset=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2018\/11\/4_DebugConsole.png 692w, https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2018\/11\/4_DebugConsole-300x106.png 300w\" sizes=\"(max-width: 692px) 100vw, 692px\" \/><\/p>\n<p>Completions are based on variables available at runtime in the current scope.<\/p>\n<h2>Automatic detection of new virtual environments<\/h2>\n<p>The Python extension will now detect new virtual environments that are created in your workspace root while Visual Studio Code is running. You can create virtual environments from the terminal, and they are immediately available to select by clicking on the interpreter selector in the status bar, or by using the\u00a0<strong>Python: Select Interpreter<\/strong>\u00a0command.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter wp-image-6888 size-full\" src=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2018\/11\/5_VenvDetection.png\" alt=\"Virtual environments are available in the Interpreter Selector after creating them in the console\" width=\"537\" height=\"251\" srcset=\"https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2018\/11\/5_VenvDetection.png 537w, https:\/\/devblogs.microsoft.com\/python\/wp-content\/uploads\/sites\/12\/2018\/11\/5_VenvDetection-300x140.png 300w\" sizes=\"(max-width: 537px) 100vw, 537px\" \/><\/p>\n<p>In the screenshot above\u00a0 a new virtual environment named \u201cenv\u201d was created in the terminal, and then set the active environment, as indicated by\u00a0<strong>&#8216;env&#8217;\u00a0<\/strong>in the status bar. Previously you had to reload Visual Studio Code for the new environment to be available.<\/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. The full list of improvements is listed in our\u00a0<a href=\"https:\/\/github.com\/Microsoft\/vscode-python\/blob\/master\/CHANGELOG.md\">changelog<\/a>; some notable changes include:<\/p>\n<ul>\n<li>Add\u00a0<u><a href=\"https:\/\/pypi.org\/project\/bandit\/\">bandit<\/a><\/u>\u00a0to supported linters. (thanks\u00a0<u><a href=\"https:\/\/github.com\/demus\/\">Steven Demurjian Jr.<\/a><\/u>) (<u><a href=\"https:\/\/github.com\/Microsoft\/vscode-python\/issues\/2775\">#2775<\/a><\/u>)<\/li>\n<li>Added a debugger setting to show return values of functions while stepping. (<u><a href=\"https:\/\/github.com\/Microsoft\/vscode-python\/issues\/2463\">#2463<\/a><\/u>)<\/li>\n<li>Language server completion support for\u00a0<a href=\"https:\/\/docs.python.org\/3\/library\/collections.html#collections.namedtuple\">namedtuple<\/a>,\u00a0<a href=\"https:\/\/docs.python.org\/3\/library\/typing.html#typing.NewType\">typing.NewType<\/a>,\u00a0<a href=\"https:\/\/docs.python.org\/3\/library\/typing.html#typing.TypeVar\">typing.TypeVar<\/a>, and generic containers.<\/li>\n<li>Add debugger support for\u00a0<a href=\"https:\/\/pypi.org\/project\/PySide2\/\">pyside2<\/a>. (<a href=\"https:\/\/github.com\/Microsoft\/vscode-python\/issues\/3235\">#3235<\/a>)<\/li>\n<\/ul>\n<p>Be sure to\u00a0<a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=ms-python.python\">download the Python extension<\/a>\u00a0for Visual Studio Code now to try out the above improvements. If you run into any problems, please file an issue on the\u00a0<a href=\"https:\/\/github.com\/Microsoft\/vscode-python\">Python VS Code GitHub<\/a>\u00a0page.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We are pleased to announce that the October 2018 release of the Python Extension for Visual Studio Code is now available. In this release we have closed a total of 49 issues, including Jupyter support: import notebooks and run code cells in a Python Interactive window, use new virtual environments without having to restart, code completions in the debug console window, improved completions in language server: recognition of namedtuple, and generic types.<\/p>\n","protected":false},"author":883,"featured_media":6886,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[6],"tags":[],"class_list":["post-6875","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-visual-studio-code"],"acf":[],"blog_post_summary":"<p>We are pleased to announce that the October 2018 release of the Python Extension for Visual Studio Code is now available. In this release we have closed a total of 49 issues, including Jupyter support: import notebooks and run code cells in a Python Interactive window, use new virtual environments without having to restart, code completions in the debug console window, improved completions in language server: recognition of namedtuple, and generic types.<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/posts\/6875","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\/883"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/comments?post=6875"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/posts\/6875\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/media\/6886"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/media?parent=6875"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/categories?post=6875"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/python\/wp-json\/wp\/v2\/tags?post=6875"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}