Python in Visual Studio Code – January 2020 Release
We are pleased to announce that the January 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.
In this release we addressed 59 issues, including:
- Kernel selection in Jupyter Notebooks
- Performance improvements in the Jupyter Notebook editor
- Auto-activation of environments in the terminal on load (thanks Igor Aleksanov!)
- Fixes to rebuilding ctags on save and on start
If you’re interested, you can check the full list of improvements in our changelog.
Kernel selection in Jupyter Notebooks
In the top right of the Notebook Editor and the Interactive Window, you will now be able to see the current kernel that the notebook is using along with the kernel status (i.e. whether it is idle, busy, etc…). This release also allows you to change your kernel to other Python kernels. To change your current active kernel, click on the current kernel to bring up the VS Code kernel selector and select which kernel you want to switch to from the list.
Performance improvements in the Jupyter Notebook editor!
This release includes many improvements to the performance of Jupyter in VS Code in both the Notebook editor and the Interactive Window. This was accomplished through caching previous kernels and through optimizing the search for Jupyter. Some of the significant improvements due to these changes are:
- Initial starting of the Jupyter server is faster, and subsequent starts of the Jupyter server are more than 2X faster
- Creating a blank new Jupyter notebook is 2X faster
- Opening Jupyter Notebooks (especially with a large file size) is now 2x faster
Note: these performance calculations were measured in our testing, your improvements may vary.
Auto-activation of environments in the terminal on load
When you have a virtual or conda environment selected in your workspace and you create a new terminal, the Python extension activates the selected environment in that new terminal. Now, this release includes the option of having environments to be auto activated in an already open terminal right when the Python extension loads.
To enable this feature, you can add the setting “python.terminal.activateEnvInCurrentTerminal“: true to your settings.json file. Then when the extension loads and there’s a terminal open in VS Code, the selected environment will be automatically activated.
Fixes to rebuilding ctags on save and on start
The ctags tool is responsible for generating workspace symbols for the user. As a result, the document outline becomes populated with file symbols, allowing you to easily find these symbols (such as functions) within your workspace.
This release includes a fix for the most upvoted bug report on our GitHub repo (GH793), related to ctags. Now, tags stored in the .vscode folder for your project can be rebuilt when the Python extension loads by setting “python.workspaceSymbols.rebuildOnStart” to true, or rebuilt on every file save by setting “python.workspaceSymbols.rebuildOnFileSave” to true.
You can learn more about ctags support in our 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:
- Support the ability to take input from users inside of a notebook or the Interactive Window. (#8601)
- Support local images in markdown and output for notebooks. (#7704)
- Support saving plotly graphs in the Interactive Window or inside of a notebook. (#7221)
- Use “conda run” when executing Python and an Anaconda environment is selected. (#7696)
- Activate conda environment using path when name is not available. (#3834)
- Add QuickPick dropdown option to Run All/Debug All parametrized tests. (thanks to Philipp Loose) (#5608)
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.