Automatically activating conda environment in integrated terminal

Viewed 1943

I have an anaconda virtual environment that I wish to use. I am able to use Select Interpreter, which finds and allows me to accurately select said virtual environment. I am also able to use this with jupyter notebooks. What I am not able to do is have the integrated terminal automatically activate this environment.

Every time I open a new terminal, I have:

(base) PS C:\working_folder

If I manually activate the environment in the integrated terminal, I am then able to use it. My issue is that I don't want to have to remember to manually activate it.

Things I've tried:

  • Setting "Python.terminal.activateEnvironment" to true
  • Setting "Python.terminal.activateEnvInCurrentTerminal" to true
  • Updating pythonPath in my working folder settings.json
1 Answers

Open Powershell and run as Administrator, execute the following command

conda config --set auto_activate_base true

Then restart VS Code, add the following in User Settings.json:

"python.defaultInterpreterPath": "\\path\\to\\conda\\python.exe",
"Python.terminal.activateEnvironment": true,
"Python.terminal.activateEnvInCurrentTerminal": true

Reload Window from Command Palette, select base:conda as python interpreter then press Ctrl+Shift+` to open a new integrated Terminal, conda environment should be activated automatically in it.

Related