How to activate conda environment from powershell?
Solution 1
You don't need Admin permission.
Once you install Anaconda or Miniconda on Windows, open a Anaconda Powershell Prompt
from Start Menu.
Or, If you don't see it there, then assuming you have installed miniconda3 at path C:\miniconda3\4.9.2, do:
powershell -ExecutionPolicy ByPass -NoExit -Command "& 'C:\miniconda3\4.9.2\shell\condabin\conda-hook.ps1' ; conda activate 'C:\miniconda3\4.9.2' "
Now try:
conda init powershell
and reopen powershell.
Additional note: By default conda will autoactivate itself, when we open terminal. If you prefer not, then disable auto-activation with:
conda config --set auto_activate_base false
Solution 2
Open a Anaconda Powershell Prompt
from Start Menu.
Now Try:
conda init powershell
Now restart the powershell, if find some error like this in powershell:
\WindowsPowerShell\profile.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170. At line:1 char:3
Then change the execution policy. Type this code to powershell:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
To find more with execution policy you can visit this link.
Solution 3
When you use Anaconda or Miniconda type in Anacondaprompt:
conda init powershell
Solution 4
Here is my easier solution which works with Anaconda, Miniconda, and even Miniforge:
- Open Powershell and browse to
condabin
folder in your conda installation directory, for example:C:\Users\<username>\anaconda3\condabin
- Run
./conda init powershell
in that folder, and re-open the powershell. - Please note: If you encountered
ps1 cannot be loaded because running scripts is disabled on this system
, simply run the Powershell as Administrator and enter the following:Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted
- Restart the Powershell & Enjoy!
Solution 5
In order to activate conda on Powershell, I just executed this command:
C:\Users\<username>\anaconda3\shell\condabin\conda-hook.ps1
Then I could see all environments without needing to restart Powershell.
conda env list
conda activate base
So you need to basically just run the conda-hook.ps1
script.

Z Chen
Updated on July 09, 2022Comments
-
Z Chen 11 months
Version
Anaconda 4.8.3
What I cannot do:
I can't activate any environment from powershell.conda activate base
What I can do:
conda env list
conda create -n xxx
conda remove -n xxx
I have tried many solutions, but they turn out to be useless:
-
conda init powershell
restart powershell
conda activate
-
conda update -n base conda
and redo 1 -
conda install -n root -c pscondaenvs pscondaenvs
Set-ExecutionPolicy RemoteSigned
Runactivate base
-
AMC over 2 yearsWere you running Powershell with elevated/admin permissions when you tried
conda init
? There were no errors? -
Z Chen over 2 yearsYeah, I tried both admin and non-admin powershell, and the result turns out the same. " no change <path of some .exe's and .bat's>" @AMC
-
-
CheTesta almost 2 yearsSolution looked promising, but actually it is not bypassing the restriction and after restart (with full modificatoin of files by conda) it is still not working properly. On restart the same
\WindowsPowerShell\profile.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170. At line:1 char:3
(referencing the automatically created ps script) -
gcharbon over 1 yearIn this case you simply need to unblock the file named
profile.ps1
:Unblock-File -Path .\profile.ps1
(replace relative path with full path) See Unblock-File cmdlet doc -
Winand over 1 yearwithout admin priviliges:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
-
Deepak Saini about 1 yearWow, this worked for me after trying multiple things