Python Anaconda:我应该在linux中使用`conda activate`还是`source activate`
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/49600611/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Python Anaconda: should I use `conda activate` or `source activate` in linux
提问by krishnab
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.
所以我习惯source activate <environment>
在启动python Anaconda环境时打字。这工作得很好。但是,当我创建新的 conda 环境时,我在 Ubuntu 16.04 上看到了用于启动环境的消息conda activate
。除了关于如何设置我的 shell 以使用的错误之外conda activate
,我仍然不清楚source activate ...
和conda activate ...
是否有理由改变之间的区别?有谁知道这两个命令之间的区别?谢谢。
回答by sacuL
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 hugeimprovement IMO).
从 conda 4.4 开始,conda activate
是激活环境的首选方式。一般来说,你不会发现conda activate
和旧的有太大区别source activate
,除了它意味着更快,并且在不同的操作系统上工作相同(后者的差异使IMOconda activate
有了巨大的改进)。
From the docs, regarding the release of conda version 4.4.0
(released December 2017):
从文档中,关于 conda 版本的4.4.0
发布(2017 年 12 月发布):
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.
conda activate:重新设计了环境激活的逻辑和机制。在 conda 4.4 中, conda activate 和 conda terminate 现在是用于激活和停用环境的首选命令。您会发现它们比以前 conda 版本中的 source activate 和 source activate 命令更加快捷。conda activate 命令还具有以下优点:(1) 在所有操作系统、shell 和平台上通用,以及 (2) 不会与来自其他包(如 python virtualenv 的 activate 脚本)的脚本发生路径冲突。
回答by taper
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:
这是我发现的一个区别。source activate
可以在 bash 脚本的开头使用来加载 conda 环境,而conda activate
会给我一个错误:
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.
这对我产生了巨大的影响,因为我经常将 bash 作业提交到集群,并且source activate
是更改 conda 环境的唯一方法。
Please correct me if anyone can use conda activate
in a bash script.
如果有人可以conda activate
在 bash 脚本中使用,请纠正我。