selected python interpreter is not written in user/workspace setting in visual studio code

858 views Asked by At

I use VSC latest version (1.59) on mac/osx. When i modify some settings usually they should be recorded in the user setting. If i open my setting in json format , some lines will look like this :

"workbench.settings.editor": "json",
"workbench.colorTheme": "Monokai",
"workbench.iconTheme": "ayu",

That's the changes i made to the color theme and file icon. But when i change my python interpreter in the command palette -> python:select interpreter, the changes i made is not recorded/written there. I expect line like :

python.defaultInterpreterPath = .....

But i doesn't exist. It actually behaves properly and use the selected python interpreter as expected but it's just not being written to the user setting.json file inside my user directory (/Users/andi/Library/Application Support/Code/User/setting.json) or inside the .vscode folder in current project.

Does anyone know where this setting has been written to ?

1

There are 1 answers

4
Steven-MSFT On

It will modify the setting of python.pythonPath instead of python.defaultInterpreterPath in your Workspace setting.

The explanation of python.defaultInterpreterPath(official docs):

Path to the default Python interpreter to be used by the Python extension on the first time it loads for a workspace, or the path to a folder containing the Python interpreter. Can use variables like ${workspaceFolder} and ${workspaceFolder}/.venv. Using a path to a folder allows anyone working with a project to create an environment in the .venv folder as appropriate to their operating system, rather than having to specify an exact platform-dependent path. settings.json file can then be included in a source code repository. Note: Changes to this setting made after an interpreter has been selected for a workspace will not be applied or considered by the Python extension. As well, the Python extension doesn't automatically add or change this setting.

Update:

Sorry for that. For testing, I have used the Python Extension with an older version. python.pythonPath can not be changed in the new version.

python.defaultInterpreterPath only work for the first time, and will not be changed when you switch the python interpreter(official docs).

A new optional setting python.defaultInterpreterPath is introduced in the user and workspace scope, from which the extension will read the value when loading a project for the first time.

Changes to the python.defaultInterpreterPath will not be picked up by the Python extension once an interpreter is already selected for the workspace. The extension will also not set nor change the value of this setting, it will only read from it.

In fact, the python interpreter path will be stored in the local storage and you can not modify it.