0

I am using VS code and have a venv folder for shared projects that lives outside of workspace/project folders. I want to change my workspace to use the interpreter within my AppData\local... folder (system installation of Python). I have been reading up on this but not found a solution to do this. How would I do this please?

enter image description here

I should note that the virtual environment is not active so I can not do this.

In the terminal I see this showing the workspace folder & the virtual environment. enter image description here

This is messing up my debugging and very frustrating.

Edit - to try better explain when opening my interpreter list (see image below). Each workspace (red box) has the interpreter named under it (green box). I want to change the interpreter that is linked to the workspace.

enter image description here

Edit2 - solution - So I was able to fix this by doing something I had tried before but for some reason this time it worked. Which was selecting the 'Select at workspace level' option.

enter image description here

Then I selected the interpreter and this time it allowed me to browse for the interpreter on my computer which then updated the interpreter. Don't see what the problem was but it worked.

enter image description here

Cam
  • 1,263
  • 13
  • 22
  • Does this answer your question? [How can I set up a virtual environment for Python in Visual Studio Code?](https://stackoverflow.com/questions/54106071/how-can-i-set-up-a-virtual-environment-for-python-in-visual-studio-code) – sahasrara62 Aug 29 '22 at 21:52
  • Not sure it does. I don't want to create a new environment but to switch from a virtual environment to the system install of python. – Cam Aug 29 '22 at 22:11

1 Answers1

0

You can use shortcuts "ctrl+shift+P" and type "Python: Clear Workspace Interpreter Settings" AND "Python: Select Interpreter" to change the environment.

By default, the Python extension looks for and uses the first Python interpreter it finds in the system path. To select a specific environment, use the Python: Select Interpreter command from the Command Palette (Ctrl+Shift+P).

You can refer to the docs for more details.

MingJie-MSFT
  • 5,569
  • 1
  • 2
  • 13
  • This does not sole the problem. In my question I show a screen shot of my interpreter list. But as you see each workspace already has an interpreter selected. I want to be able to change the interpreter for a workspace. – Cam Aug 30 '22 at 21:44
  • @Cam You can add `defaultInterpreterPath` to your `./.vscode/settings.json` in your workspace. Refer to [docs](https://code.visualstudio.com/docs/python/settings-reference#_general-python-settings) for details. I hope it will help. – MingJie-MSFT Aug 31 '22 at 01:31
  • Thanks this is a nice option to know. But it seems python.defaultInterpreterPath setting are **not** picked up after an interpreter has already been selected for a workspace; any changes to the setting will be ignored once an initial interpreter is selected for the workspace. – Cam Sep 01 '22 at 15:03
  • 1
    If you use shortcuts `ctrl+shift+P` and type `Python: Clear Workspace Interpreter Settings`, will it work? – MingJie-MSFT Sep 02 '22 at 01:22
  • My interpreter seem to go back to the virtual environment overnight but ```Python: Clear Workspace Interpreter Settings``` seemed to do the trick. thanks – Cam Sep 02 '22 at 13:31