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

前端 未结 3 2037
清歌不尽
清歌不尽 2021-01-30 20:43

So I am used to typing source activate when starting a python Anaconda environment. That works just fine. But when I create new conda environmen

相关标签:
3条回答
  • 2021-01-30 20:50

    Here is one difference I found. source activate can be used at the beginning of a bash script to load conda environment, whereas conda activate would give me an error:

    CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
    

    This makes a huge difference to me since I often submit bash jobs to cluster and source activate is the only way to change conda environment.

    Please correct me if anyone can use conda activate in a bash script.

    0 讨论(0)
  • 2021-01-30 20:54

    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:

    Then install the packages you want

    0 讨论(0)
  • 2021-01-30 21:04

    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.

    0 讨论(0)
提交回复
热议问题