3

I currently have miniconda installed and one virtualenvironment + base environment.

conda env list

# conda environments:
#
base                  *  /home/alex/miniconda3
machinelearning          /home/alex/miniconda3/envs/machinelearning

As the asterisk suggests curently I am using the base environment. In order to move to machinelearning environment do I need to activate the environment again ? Should this be the command to switch to machinelearning ? conda activate machinelearning. Do I need to deactivate from base first before doing that ? I also don't understand the difference between deactivate and remove an environment.

I read the anaconda documentation on managing environments https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#sharing-an-environment, but did not find anything explaining the differences.

moth
  • 1,833
  • 12
  • 29

1 Answers1

5

when you open the powershell, you will be on the default powershell window: PS C:\Users\some_user>

Then if you type conda activate base you will see the following line: (base) PS C:\Users\some_user

Now you are in the base environment which comes default with conda. If you want to switch to another environment you could simply type: conda activate myenv within the base environment.

(base) PS C:\Users\some_user> conda activate myenv
(myenv) PS C:\Users\some_user> 

Now when you deactivate myenv it will go back to base environment.

(myenv) PS C:\Users\some_user> conda deactivate
(base) PS C:\Users\some_user> conda deactivate
PS C:\Users\some_user>

Activating environments is essential to making the software in the environments work well. Activation entails two primary functions: adding entries to PATH for the environment and running any activation scripts that the environment may contain. These activation scripts are how packages can set arbitrary environment variables that may be necessary for their operation. You can also use the config API to set environment variables. (https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html)

When you are within an environment, the packages within that environment can be accessible. When you switch or deactivate from an environment, those packages specific to that environment will not be accessible from powershell.

When you remove an environment, it means you permanently remove environment and all the packages belong to that environment from the computer.

PS C:\Users\some_user> conda remove --name myenv --all

Remove all packages in environment C:\Users\some_user\.conda\envs\myenv:

No packages found in C:\Users\some_user\.conda\envs\myenv. Continuing environment removal
ahrooran
  • 931
  • 1
  • 10
  • 25
  • 1
    Say you have (base), along with environments (A) and (B). If you're on (A) and want to switch to (B), is there any reason to deactivate (A)? Is it sufficient to just activate (B)? – Nick Koprowicz Dec 22 '20 at 18:35
  • 1
    as far as I know it is sufficient to just activate B even when inside A. As a matter of fact I did do this out of laziness. But now when you deactivate B it will switch back to A. So to get rid of conda altogether from terminal, you would have to deactivate A again. I am not familiar with the latest versions of maven but you could experiment yourself – ahrooran Dec 23 '20 at 16:25