Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to activate conda environment from powershell?

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:

  1. conda init powershell
    restart powershell
    conda activate

  2. conda update -n base conda and redo 1

  3. conda install -n root -c pscondaenvs pscondaenvs
    Set-ExecutionPolicy RemoteSigned
    Run activate base

The result of running conda activate

like image 508
Z Chen Avatar asked Oct 01 '20 05:10

Z Chen


People also ask

How do I activate my environment conda?

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 .

What is Anaconda PowerShell prompt?

Anaconda prompt is similar to a terminal or command prompt (cmd). It refers to a black screen used to type in the commands by the user. You can download conda using a GUI installer. Let's look at series of steps to install Anaconda using the terminal in macOS.


2 Answers

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
like image 167
prashant Avatar answered Sep 17 '22 16:09

prashant


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.

like image 29
sunghangga Avatar answered Sep 18 '22 16:09

sunghangga