[英]Should conda, or conda-forge be used for Python environments?
Conda
and conda-forge
are both Python package managers. Conda
和 conda conda-forge
forge 都是 Python package 管理者。 What is the appropriate choice when a package exists in both repositories?当两个存储库中都存在 package 时,什么是合适的选择? Django, for example, can be installed with either, but the difference between the two is several dependencies (conda-forge has many more).
例如 Django,两者都可以安装,但两者的区别在于几个依赖项(conda-forge 有更多)。 There is no explanation for these differences, not even a simple README.
没有对这些差异的解释,甚至没有简单的自述文件。
Which one should be used?应该使用哪一个? Conda or conda-forge?
康达还是康达锻造? Does it matter?
有关系吗?
The short answer is that, in my experience generally, it doesn't matter which you use.简短的回答是,根据我的经验,一般来说,使用哪个并不重要。
The long answer:长答案:
So conda-forge
is an additional channel from which packages may be installed.所以
conda-forge
是一个额外的渠道,可以从中安装软件包。 In this sense, it is not any more special than the default channel, or any of the other hundreds (thousands?) of channels that people have posted packages to.从这个意义上说,它并不比默认频道或人们发布包裹的其他数百(数千?)频道中的任何一个更特别。 You can add your own channel if you sign up at https://anaconda.org and upload your own Conda packages.
如果您在https://anaconda.org上注册并上传您自己的 Conda 包,则可以添加您自己的频道。
Here we need to make the distinction, which I think you're not clear about from your phrasing in the question, between conda
, the cross-platform package manager, and conda-forge
, the package channel.在这里,我们需要区分
conda
(跨平台包管理器)和conda-forge
包通道)之间的区别,我认为您在问题中的措辞并不清楚。 Anaconda Inc. (formerly Continuum IO), the main developers of the conda
software, also maintain a separate channel of packages, which is the default when you type conda install packagename
without changing any options. conda
软件的主要开发者 Anaconda Inc.(前身为 Continuum IO)也维护了一个单独的软件包通道,这是您键入conda install packagename
而不更改任何选项时的默认设置。
There are three ways to change the options for channels.可通过三种方式更改频道选项。 The first two are done every time you install a package and the last one is persistent.
每次安装软件包时都会执行前两个,最后一个是持久的。 The first one is to specify a channel every time you install a package:
第一个是每次安装包时指定一个频道:
conda install -c some-channel packagename
Of course, the package has to exist on that channel.当然,该软件包必须存在于该频道上。 This way will install
packagename
and all its dependencies from some-channel
.这种方式将从
some-channel
安装packagename
及其所有依赖some-channel
。 Alternately, you can specify:或者,您可以指定:
conda install some-channel::packagename
The package still has to exist on some-channel
, but now, only packagename
will be pulled from some-channel
.该包仍然必须存在于
some-channel
,但现在,只会从some-channel
提取packagename
。 Any other packages that are needed to satisfy dependencies will be searched for from your default list of channels.将从您的默认频道列表中搜索满足依赖项所需的任何其他包。
To see your channel configuration, you can write:要查看您的频道配置,您可以编写:
conda config --show channels
You can control the order that channels are searched with conda config
.您可以使用
conda config
控制搜索频道的顺序。 You can write:你可以写:
conda config --add channels some-channel
to add the channel some-channel
to the top of the channels
configuration list.将频道
some-channel
添加到channels
配置列表的顶部。 This gives some-channel
the highest priority.这给予
some-channel
最高优先级。 Priority determines ( in part ) which channel is selected when more than one channel has a particular package.当多个频道具有特定包时,优先级决定(部分地)选择哪个频道。 To add the channel to the end of the list and give it the lowest priority, type
要将频道添加到列表末尾并为其赋予最低优先级,请键入
conda config --append channels some-channel
If you would like to remove the channel that you added, you can do so by writing如果你想删除你添加的频道,你可以写
conda config --remove channels some-channel
See见
conda config -h
for more options.更多选择。
With all of that said, there are four main reasons to use the conda-forge
channel instead of the defaults
channel maintained by Anaconda: conda-forge
,使用conda-forge
通道而不是 Anaconda 维护的defaults
通道有四个主要原因:
conda-forge
may be more up-to-date than those on the defaults
channel conda-forge
软件包可能比defaults
频道上的软件包更新conda-forge
channel that aren't available from defaults
conda-forge
频道上的某些软件包defaults
不可用openblas
(from conda-forge
) instead of mkl
(from defaults
).openblas
(来自openblas
conda-forge
mkl
)而不是mkl
(来自defaults
)。Anaconda has changed their Terms of Service so that "heavy commercial users" would have to pay, which doesn't include conda-forge
channel. Anaconda 更改了他们的服务条款,以便“重度商业用户”必须付费,其中不包括
conda-forge
频道。
You probably would want to stick to conda-forge
if you don't want to pay for the usage.如果您不想为使用付费,您可能希望坚持使用
conda-forge
。 As stated in the docs :如文档中所述:
conda config --add channels conda-forge
conda config --set channel_priority strict
conda install <package-name>
You could also use miniforge which has conda-forge
as the default channel, and supports ppc64le and aarch64 platforms as well as the other usual ones.您也可以使用miniforge ,它以conda
conda-forge
forge作为默认通道,并支持 ppc64le 和 aarch64 平台以及其他常用平台。
If you have conda
installed and would like to remove the default channels, you can use如果您安装了
conda
并想删除默认频道,您可以使用
conda config --show channels
to see your channels, and can use查看您的频道,并可以使用
conda config --remove channels channel-name
to remove a channel.删除频道。
The conda-forge channel is where you can find packages that have been built for conda but yet to be part of the official Anaconda distribution.在 conda-forge 频道中,您可以找到为 conda 构建但尚未成为官方 Anaconda 发行版的一部分的软件包。
Generally, you can use any of them.通常,您可以使用其中任何一个。
In my experience the channel conda-forge
provides more packages and they are also more up-to-date.根据我的经验,
conda-forge
频道提供了更多的软件包,而且它们也是最新的。 That is why I use it as my default channel which can be done like so这就是为什么我将它用作我的默认频道,可以这样做
conda config --add channels conda-forge
conda config --set channel_priority strict
There are some Python libraries that you cannot install with a simple conda install
since their channel is not available unless you apply conda-forge.有些 Python 库无法通过简单的
conda install
因为除非您应用 conda-forge,否则它们的频道不可用。 From my experience, pip is more generic to look into different channel sources than conda.根据我的经验,pip 比 conda 更通用,可以查看不同的渠道来源。 For instance, if you want to install
python-constraint
you can do it via pip install
but to install it via **cond **.例如,如果你想安装
python-constraint
你可以通过pip install
来安装,但是通过 **cond ** 安装它。 you have to specify the channel - conda-forge
.您必须指定通道 -
conda-forge
。
conda install -c conda-forge python-constraint // works
but not但不是
conda install python-constraint
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.