How to activate different anaconda environment from powershell
Solution 1
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
Solution 2
I found this solution:
I've been building on BCSharp's excellent work at my own repo (currently on PR).
Just do:
conda install -n root -c pscondaenvs pscondaenvs
You need Conda 4.1 or above (check with conda info conda) - otherwise please install the latest version.
Behavior is exactly like CMD - use activate or deactivate appropriately. It's completely backwards compatible and will also launch both .ps1 and .bat activate.d/deactivate.d scripts.
from https://github.com/conda/conda/issues/626#issuecomment-346224990 has worked really well for me.
Solution 3
I have been battling this issue for a while. I found a solution by using a batch script and calling call activate %env%
. I hope this can help somebody.
Hector Barbossa
Updated on April 29, 2021Comments
-
Hector Barbossa about 3 years
I have two environments in anaconda, namely:
root
,2env
. When I open anaconda prompt, I can switch fromroot
to2env
by typing:activate 2env
. I also have conda in my powershell, but when I open powershell and try to runconda activate 2env
it gives the following error:CommandNotFoundError: 'activate'
Any suggestions on how to fix this?
-
Seanny123 about 5 yearsThis no longer works with Conda 4.6, which resolves issue #626.
-
GoingMyWay almost 5 yearsIt cannot activate the virtualenv.
-
jCisco almost 5 years@GoingMyWay Conda 4.6.14 is functional
-
not2qubit about 4 yearsIf for some reason you are using a custom prompt (for something else), it gets messed up by the activate. But you can fix it, if you're good at PS profile hacking and adding:
if ("$env:CONDA_PROMPT_MODIFIER" -match "(base)") { ... }
. -
Seanny123 about 4 years@not2qubit I think that would be a valid question-answer pair which you could link to
-
wordsforthewise about 3 yearsDoes
conda init powershell
need to be run from powershell, or can it be run from a command prompt?