Python Anaconda: should I use `conda activate` or `source activate` in linux

Go To StackoverFlow.com

19

So I am used to typing source activate <environment> when starting a python Anaconda environment. That works just fine. But when I create new conda environments I am seeing the message on Ubuntu 16.04 to start the environments with conda activate instead. Besides the errors about how to set up my shell to use conda activate instead, I am still not clear on what is the difference between source activate ... and conda activate ... Is there a reason to change? Does anyone know the difference between these two commands? Thanks.

2018-04-01 17:14
by krishnab


30

As of conda 4.4, conda activate is the preferred way to activate an environment. Generally, you won't find too much of a difference between conda activate and the old source activate, except that it's meant to be faster, and work the same across different operating systems (the latter difference makes conda activate a huge improvement IMO).

From the docs, regarding the release of conda version 4.4.0 (released december 2017):

conda activate: The logic and mechanisms underlying environment activation have been reworked. With conda 4.4, conda activate and conda deactivate are now the preferred commands for activating and deactivating environments. You’ll find they are much more snappy than the source activate and source deactivate commands from previous conda versions. The conda activate command also has advantages of (1) being universal across all OSes, shells, and platforms, and (2) not having path collisions with scripts from other packages like python virtualenv’s activate script.

2018-04-01 17:27
by sacuL
Ahh, I see. I did not see this section in the documentation, so thanks for pointing it out. I see the difference now. Drat, now I have to go and update my zsh config and bash config, and .... :) - krishnab 2018-04-01 17:55
Yeah... someone should really update the rest of the documentation, because the only info I found (what I posted above) is hidden away in the release notes.. - sacuL 2018-04-01 17:57
Haha, there is so much Anaconda documentation out there now, I imagine even the Continuum folks have a hard time knowing where to update stuff after each change :). But I guess it is the same way all around. I was installing Tensorflow-gpu the other day and that documentation is even worse--because the package installs are very tightly linked to the cuda versions and such. That was a pain. At least the Anaconda error message tells me what to do :) - krishnab 2018-04-01 18:01
the problem with conda activate is that it assumes that conda is already in your PATH; source activate was typically how I put conda in my PATH in the first place - user5359531 2019-02-19 14:01


-2

I am using Anaconda Navigator 1.8.2 with Spyder 3.2.8 on Mac OS, I think is similar to Linux.

It's very easy to install a virtualenv with Anaconda:

Create a new virtualenv

Select python version

Install packages

Then install the packages you want

2018-04-01 17:23
by pfRodenas
Thanks @pfRodenas I have been using Anaconda since it first came out :). Definitely much better than the thing we used to use before, which was the Enthought distribution. But my question was about the activation of new environments using the conda command. I have never used the Anaconda navigator though. I guess it is something to try - krishnab 2018-04-01 17:57
Ads