Skip to content

Setting descriptions

Kartik Raj edited this page Jun 8, 2022 · 3 revisions

python.defaultInterpreterPath

TL;DR

In short,

  • The python.pythonPath setting is no longer used by the Python extension.
  • python.defaultInterpreterPath is introduced in the user and workspace scope, from which the extension will read the value when loading a project.
  • Particularly at workspace scope,
    • Changes to the python.defaultInterpreterPath will not be picked up by the Python extension once user explicitly chooses a different interpreter for the workspace. The extension will also not set nor change the value of this setting, it will only read from it.
    • A VSCode internal storage is introduced which will now store the interpreter settings in the workspace & workspace folder scope. i.e workspace settings are no longer stored in settings.json/.code-workspace, but an internal storage.
      • You can change the value stored in workspace settings using Python: Select Interpreter command.
      • See the Python output channel to check the value of the interpreter selected.
      • You can clear the value stored using Python: Clear Workspace Interpreter Setting command.
  • At user scope, extension uses python.defaultInterpreterPath to control the selected interpreter, and will pick up any changes made to it.

Description

Previously, the path to the interpreter was stored in the python.pythonPath setting, as specified in the settings.json file. However, this storage method caused problems for users that work on teams that don’t use the same OS, or simply work with interpreters that don’t share the same path. In these situations, the setting is not valid across the team, making the process of storing a project’s settings.json in version control difficult.

For those who do want to add this setting to version control, you can use the python.defaultInterpreterPath setting instead, which the Python the extension will read values from when loading the project for the first time. Changes to this value are not dynamically picked up, i.e. changes to this setting after an interpreter has already been selected on a workspace will not be applied. The Python extension will also not add this setting nor modify its value at any point.

Experience

• The path to the workspace interpreter will now be stored in VS Code’s persistent storage instead of the settings.json file.

• For users that want to set a default interpreter for a workspace, you can use the new setting python.defaultInterpreterPath.

• For 3rd party extensions that need access to the Python path, you can retrieve it using the extension API. It's also possible to retrieve it using the command ${command:python.interpreterPath}.

• You can change workspace-specific value using Python: Select Interpreter command. When using the command on the Command Palette, a new option exists to specify an interpreter path.

• You can clear the value stored in workspace settings using Python: Clear Workspace Interpreter Setting command.

Clone this wiki locally