I use Python mostly in Spyder for data science. Both Visual Studio Code and virtual environments is fairly new to me.
Anyway, using the terminal in Visual Studio Code I try to switch between environments. I have tried both conda activate venv
and activate venv
. I get no error message but using conda env list
to see which environment is active I seem stuck in Base.
Doing the same thing in the Anaconda Prompt I am allowed to switch between environments.
I use Windows and I start Visual Studio Code from the Anaconda Navigator.
What is going on?
You need to set your VScode terminal as cmd.exe and not as PowerShell.
#########UPADTE##########
The solution under is deprecated, the new solution can be found in the documentation here:
#########################
Here is how to change your default terminal,
or you can change your settings.json file as follow:
"terminal.integrated.shell.windows": "C:\\Windows\\System32\\cmd.exe"
From documentation:
Note: conda environments cannot be automatically activated in the integrated terminal if PowerShell is set as the integrated shell.