pythonvisual-studio-codeenvironmentanaconda3

Visual Studio Code terminal shows multiple Conda envs


I have VSCode in Windows 11. I have WSL (Ubuntu 22.04) and launch VSCode from the terminal like code . from the project folder. When I open the built-in terminal it shows two conda (Anaconda) environments in parentheses, so I have no idea which one is active, if any. On subsequent conda deactivate you can see in the attached screenshot that the prompt and the active env changing but there is surely something messed up here.

Also, in VSCode, when I set Python Interpreter to a conda env, in a few seconds the built-in terminal prompt picks up the change and the env name in the first parens changes to the new value.

Any idea how to fix it?

(The prompt should obviously show just one (the active) conda env and that one should change whenever the Python interpreter is updated in the command palette.)

enter image description here

I looked into my ~/.bashrc file but there is just the seemingly normal >>> conda initialize block at the bottom that was added when installing Anaconda


Solution

  • It turns out that I had to delete ~/.vscode-server directory and let it being autogenerated again on the next code . run. I also had to click the "Inherit Env" setting of the built-in Terminal (I forgot, it may not be the default).

    With these steps, a newly launched VSCode behaves almost exactly like I expected:

    anyways, I think I can live with this

    enter image description here