Python in Visual Studio Code – May 2020 Release
We are pleased to announce that the May 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 42 issues, and it includes the ability to browse for or enter an interpreter path on selection. If you’re interested, you can check the full list of improvements in our changelog.
Ability to browse for interpreter path
To make selecting or changing interpreter easier, you now have the option to browse for a Python interpreter in your file system. You can also set an interpreter by manually entering its path:
Coming Next: moving python.pythonPath out of settings.json
One change that is coming relates to how the Python extension handles Python interpreter selection. Currently the path to the selected interpreter is stored in the workspace settings. This can be a problem when you share VS Code workspace settings in a GitHub repo, for example, as reported in our issue tracker.
In order to make the interpreter information system agnostic and prevent sharing the interpreter path (which commonly won’t be the same across different machines), we’re going to deprecate the python.pythonPath setting in the Python extension. You will still be able to set interpreters per workspace, it’ll just be stored internally instead of the workspace settings.
These changes will be added gradually as an experiment. If you’re interested to try it ahead of time, you can opt into this functionality by adding the following line to your User settings (View > Command Palette… and run Preferences: Open Settings (JSON)) and then reloading the window (View > Command Palette… and run Developer: Reload Window):
"python.experiments.optInto": ["DeprecatePythonPath - 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 in general, you can open the user settings.json file and set the “python.experiments.enabled” setting to false.
We also have some additional announcements coming soon, so stay tuned!
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:
- CVE-2020-1171: Do not perform pipenv interpreter discovery on extension activation. (#11127)
- CVE-2020-1192: Setting “Data Science: Run Startup Commands” is now limited to being a User scope only setting.
- Performance improvements when executing multiple cells in Notebook and Interactive Window using ipywidgets. (#11576)
- Fix for opening the interactive window when no workspace is open. (#11291)
- Update Jedi 0.17 (thanks Peter Law) (#11221)
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.
I am just adding my .vscode directory to .gitignore anyway. Why should we share IDE settings in a repository? Weird change but I guess there is some use case.
It can be useful if you’re working on a project with a team, and you all want to use the same formatter, linting and editor settings overall. We’ve heard from a lot of users that they would like to not add .vscode to .gitignore because it’d be useful to share some settings, but they often did solely because of the existence of python.pythonPath setting.
Interesting change in the pythonPath. Where will it live once deprecated from the settings.json?
It will be located in VS Code’s persistent storage. It’s also worth mentioning that the path to the selected interpreter will be printed in the Output panel, and that we’re also working on a documentation to clarify these changes.
pythonPath is perfect for everyone who uses venv instead of pipenv and it works with WSL on Windows.
You will still be able to select interpreters per workspace, like for venv. We’ll just stop storing it in the settings.json file, it’ll exist in VS Code’s persistent storage instead. You’ll also be able to copy the path to the selected interpreter from the Output panel.
For a smooth experience with WSL, we recommend the Remote – WSL extension.
I don’t agree that discontinuing interpreter configuration in vscode config is useful. You can already apply it in user settings instead of project. Adding it to the project is just an option tha people can easily skip
You will continue to be able to specify the setting per workspace. We are simply storing it using VS Code’s persistent storage instead of your settings file, so you will continue to need to only set it once. Taking this setting out of the file allows it to be committed to version control and shared among team members.