0

When installing Anaconda, a script is added to the .bash_profile. This script seems to activate the base environment as the shell starts with:

(base) ComputerName:~ login$

What is the difference with a login script that does not activate any environment? Why is the base environment activated?

Should I install new package with conda install package in the base environment or outside of it?

InsideLoop
  • 5,803
  • 2
  • 23
  • 49
  • 1
    The base environment is activated because the conda installer assumes that you want to use conda because you're installing it. You can deactivate it if you want, see https://stackoverflow.com/a/54560785/2449192 – darthbith Apr 10 '19 at 13:30

1 Answers1

1

Anaconda is based on conda which is a package and environment manager. However, conda is also a package so it can't run without Python. In other words, some environment must be activated. It seems reasonable to activate base as default. Moreover base definitely contains all the necessary packages, for example, packages to work with secured connections (ssl).

You may install new packages into base or create another environment. It depends on you and how you use Python. Not sure what to do? Not a problem. Just google something like python why do i need virtual environment to learn more from dozens of sources.

Poolka
  • 2,841
  • 2
  • 7
  • 19
  • 2
    Technically, with the most recent conda versions (4.6 and higher), you don't need an environment activated to use conda. Simply type `conda deactivate`. The `conda` command will still be available (you can type `conda activate env-name` to activate an environment, for instance). I'm not sure what would happen if you tried to install a package without specifying an environment name though... – darthbith Apr 10 '19 at 13:29
  • @darthbith Thank you for the note. Never thought of conda as something independent. – Poolka Apr 10 '19 at 14:00
  • @darthbirth : That's exactly what I came to realise: conda is still available even though the base environment is desactivated. Moreover, I get the feeling that with previous versions of Anaconda, the initialization script was just changing the PATH environment variable without activating anything. – InsideLoop Apr 10 '19 at 14:22
  • @InsideLoop That's correct, although changing the PATH variable implicitly semi-activates the base environment by putting Conda's Python first. Now, the `conda` command is actually a shell script that calls out to a Python script so it still does rely on Conda's Python being present in the base environment, just not for that environment to be activated. – darthbith Apr 10 '19 at 16:09
  • @darthbith: Thanks. You say that the environment is "semi-activated". Is there a difference between that and between being fully activated? – InsideLoop Apr 10 '19 at 18:14
  • Yes, fully activating an environment runs the "activation scripts" that are defined for that environment, if any, and puts the environment first on the PATH. The activation scripts may be used to, e.g., change other environment variables or settings to make sure the environment is able to work consistently. – darthbith Apr 10 '19 at 20:29