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.)
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
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:
(base)
env but immediately picks up correct end and returns correct prompt(base)
env, see bottom left tab, but any subsequent new terminal added will look like the right window, which is now correct. This is still a bit inconvenient, having to either do a manual conda activate <correct_env>
or close the terminal and open a fresh one, now with the correct conda envanyways, I think I can live with this