问题:是否应将conda或conda-forge用于Python环境?

Conda并且conda-forge都是Python软件包管理器。当两个存储库中都存在一个程序包时,合适的选择是什么?例如,Django可以安装其中之一,但是两者之间的区别是几个依赖项(conda-forge还有更多)。对于这些差异没有任何解释,甚至没有简单的自述文件。

应该使用哪一个?康达或康达伪造?有关系吗?

Conda and conda-forge are both Python package managers. What is the appropriate choice when a package exists in both repositories? Django, for example, can be installed with either, but the difference between the two is several dependencies (conda-forge has many more). There is no explanation for these differences, not even a simple README.

Which one should be used? Conda or conda-forge? Does it matter?


回答 0

简短的回答是,根据我的经验,通常使用哪种都无关紧要。

长答案:

所以conda-forge是可以从其中安装的软件包的附加通道。从这个意义上讲,它没有比默认频道更特别,也没有其他任何人将软件包发布到的频道(数千个)中的任何一个。如果您在https://anaconda.org上注册并上传自己的Conda软件包,则可以添加自己的频道。

在这里,我们需要进行区分,我认为您对问题的措辞不清楚conda,即跨平台的程序包管理器和conda-forge程序包通道之间。该conda软件的主要开发人员Anaconda Inc.(以前称为Continuum IO)也维护一个单独的软件包频道,这是您在conda install packagename不更改任何选项的情况下键入的默认软件包。

有三种方法可以更改频道选项。每次安装软件包时,前两个步骤都会完成,而后一个则是持久性的。第一个是在每次安装软件包时指定一个通道:

conda install -c some-channel packagename

当然,该程序包必须存在于该通道上。这样将从进行安装packagename及其所有依赖项some-channel。或者,您可以指定:

conda install some-channel::packagename

该程序包仍然必须存在some-channel,但现在只能packagename从中提取some-channel。可以从您的默认频道列表中搜索满足依赖关系所需的任何其他软件包。

要查看您的频道配置,您可以编写:

conda config --show channels

您可以使用来控制搜索频道的顺序conda config。你可以写:

conda config --add channels some-channel

将通道添加some-channelchannels配置列表的顶部。这具有some-channel最高的优先级。当一个以上通道具有特定程序包时,优先级(部分)确定选择哪个通道。要将频道添加到列表的末尾并赋予其最低的优先级,请输入

conda config --append channels some-channel

如果您想删除添加的频道,可以通过以下方式删除

conda config --remove channels some-channel

看到

conda config -h

有关更多选项。

综上所述,使用conda-forge频道而不是defaultsAnaconda维护频道的主要原因有四个:

  1. 上的软件包conda-forge 可能defaults频道上的软件包最新
  2. conda-forge频道上的某些软件包无法从defaults
  3. 您可能希望使用诸如openblas(from conda-forge)而不是mkl(from defaults)的依赖项。
  4. 如果要安装需要编译库的软件包(例如,C扩展名或C库的包装器),则由于二进制原因,如果从单个通道在环境中安装所有软件包,则可能会减少不兼容的可能性。基本C库的兼容性(但是此建议可能会过时/将来会更改)。

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. 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.

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. 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.

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. 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. 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. You can write:

conda config --add channels some-channel

to add the channel some-channel to the top of the channels configuration list. This gives some-channel the highest priority. 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:

  1. Packages on conda-forge may be more up-to-date than those on the defaults channel
  2. There are packages on the conda-forge channel that aren’t available from defaults
  3. You would prefer to use a dependency such as openblas (from conda-forge) instead of mkl (from defaults).
  4. If you are installing a package that requires a compiled library (e.g., a C extension or a wrapper around a C library), it may reduce the chance of incompatibilities if you install all of the packages in an environment from a single channel due to binary compatibility of the base C library (but this advice may be out of date/change in the future).

回答 1

Anaconda更改了服务条款,以使“大量商业用户”需要付费,其中不包括conda-forge渠道。

conda-forge如果您不想为使用付费,则可能要坚持。如文档所述

conda config --add channels conda-forge
conda config --set channel_priority strict
conda install <package-name>

你也可以使用miniforge具有conda-forge作为默认的通道,并支持ppc64le和aarch64平台,以及其他常用的。

Anaconda has changed their Terms of Service so that “heavy commercial users” would have to pay, which doesn’t include conda-forge channel.

You probably would want to stick to conda-forge if you don’t want to pay for the usage. 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.


回答 2

在conda-forge渠道中,您可以找到针对conda构建的软件包,但尚未成为Anaconda官方发行版的一部分。

通常,您可以使用其中任何一个。

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.

Generally, you can use any of them.


回答 3

有些Python库无法简单安装,conda install因为除非应用conda-forge,否则它们的通道不可用。根据我的经验,与conda相比,pip更通用于研究不同的渠道来源。例如,如果要安装python-constraint,可以通过,pip install但可以通过** cond **进行安装。您必须指定频道- conda-forge

conda install -c conda-forge python-constraint // works

但不是

conda install python-constraint

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. From my experience, pip is more generic to look into different channel sources than conda. For instance, if you want to install python-constraint you can do it via pip install but to install it via **cond **. you have to specify the channel – conda-forge.

conda install -c conda-forge python-constraint // works

but not

conda install python-constraint

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。