Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to activate different anaconda environment from powershell

I have two environments in anaconda, namely: root, 2env. When I open anaconda prompt, I can switch from root to 2env by typing: activate 2env. I also have conda in my powershell, but when I open powershell and try to run conda activate 2env it gives the following error:

CommandNotFoundError: 'activate'

Any suggestions on how to fix this?

like image 550
Hector Barbossa Avatar asked Dec 13 '17 19:12

Hector Barbossa


People also ask

How do you activate two conda environments?

To activate your Conda environment, type source activate <yourenvironmentname> . Note that conda activate will not work on Discovery with this version. To install a specific package, type conda install -n <yourenvironmentname> [package] . To deactivate the current, active Conda environment, type conda deactivate .

How can I activate conda environment automatically?

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.

How do I change the base environment in anaconda?

Go to the start menu, right-click 'Anaconda Prompt' and go to file location. Open its properties & change the target to the location of your preferred environment.


1 Answers

Although Conda previously did not support PowerShell, this is now resolved in Conda 4.6.

After adding Anaconda3/Scripts/ to your PATH variable, you should be able to initialize Conda for use with powershell with:

conda init powershell 

Afterwards, you can use conda normally:

conda activate base 
like image 106
Seanny123 Avatar answered Oct 11 '22 06:10

Seanny123