profile
viewpoint

Ask questionsDifferent python.defaultInterpreterPath by workspace not being saved

Environment data

  • VS Code version: 1.46.1
  • OS and version: macOS Catalina 10.15.5
  • Python version (& distribution if applicable, e.g. Anaconda): Multiple 3.x versions
  • Type of virtual environment used: virtualenv / pipenv
  • Extension version: v2020.6.90262

Expected behaviour

According to https://github.com/microsoft/vscode-python/wiki/AB-Experiments workspace specific settings for the default Python interpreter should be possible via a new python.defaultInterpreterPath user setting.

Actual behaviour

python.defaultInterpreterPath is shared between multiple workspaces.

Steps to reproduce:

  1. Start a new virtualenv and VS code for project1, e.g.

user@MacBook-pro project1 % pipenv shell Launching subshell in virtual environment… . /Users/user/.local/share/virtualenvs/project1-Vn51bfDI/bin/activate user@MacBook-Pro project1 % . /Users/user/.local/share/virtualenvs/project1-Vn51bfDI/bin/activate (project1) user@MacBook-Pro project1 % code .

  1. Start a new virtualenv and VS code for project2, e.g.

user@MacBook-pro project2 % pipenv shell Launching subshell in virtual environment… . /Users/user/.local/share/virtualenvs/project2-y-K1Kf4d/bin/activate user@MacBook-Pro project2 % . /Users/user/.local/share/virtualenvs/project2-y-K1Kf4d/bin/activate (project2) user@MacBook-Pro project2 % code .

  1. In project 1, set python.defaultInterpreterPath in project1 to /Users/user/.local/share/virtualenvs/stdapplib-Vn51bfDI/bin/python

  2. In project 2, bring up Preferences to see that python.defaultInterpreterPath is already set to the virtualenv path for project1.

Comments

Maybe I'm misunderstanding how this is supposed to work, but a being able to reference a different virtualenv interpreter for each project seems to be a requirement based on the need to not lose prior functionality.

microsoft/vscode-python

Answer questions karrtikr

The setting python.pythonPath is no longer valid. We don't store interpreter path for workspaces in settings.json like we did before. Instead it's being stored in a internal VSCode storage, and you can change the value stored using Python: Select Interpreter command. The current value is printed in the Python output channel.

useful!

Related questions

Auto Scroll in the Jupyter output hot 3
Workspace contains pipfile but pipenv --venv failed hot 2
Can you turn off the Microsoft Python Language Server? hot 2
Unable to debug Python tests (duplicate entries in "env") hot 2
Jupyter server crashed. Unable to connect. Cannot assign requested address hot 2
Auto Scroll in the Jupyter output hot 2
Unable to run launch targets with newest VS Code Python extension hot 2
Unable to start jupyter python interactive window hot 1
HBox output is not shown correctly in the interactive window hot 1
Debug -> Add Debug Configuration 'Cannot read property openConfigFile' hot 1
VSCode cannot connect to jupyter server; with browser this works fine hot 1
Linux arm64/aarch64 support hot 1
Add setting to disable icon for "Run Python File In Terminal" hot 1
Extension Host keeps crashing hot 1
Activate environment before debugging tests hot 1
Github User Rank List