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

应该使用哪一种?Conda还是Conda -forge?这重要吗?


简单的回答是,根据我的经验,你用哪一种并不重要。

长话短说:

因此,conda-forge是一个可以安装软件包的附加通道。从这个意义上说,它并不比默认通道或人们已将包发布到的其他数百个(数千个?)通道中的任何一个更特殊。如果你在https://anaconda.org注册并上传你自己的Conda包,你可以添加自己的频道。

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

有三种方法可以更改通道的选项。前两个是在每次安装包时执行的,最后一个是持久执行的。第一个方法是每次安装一个包时指定一个通道:

conda install -c some-channel packagename

当然,该包必须存在于该通道上。这种方法将从某些通道安装packagename及其所有依赖项。或者,你可以指定:

conda install some-channel::packagename

包仍然必须存在于某个通道上,但是现在,只有packagename将从某个通道中提取。将从默认的通道列表中搜索满足依赖关系所需的任何其他包。

要查看你的通道配置,你可以这样写:

conda config --show channels

您可以使用conda config控制通道搜索的顺序。你可以这样写:

conda config --add channels some-channel

将通道some-channel添加到通道配置列表的顶部。这使某些通道具有最高优先级。优先级决定(部分地)当多个通道具有特定的包时选择哪个通道。若要将通道添加到列表的末尾,并赋予其最低优先级,请键入

conda config --append channels some-channel

如果要删除所添加的通道,可以通过写入操作

conda config --remove channels some-channel

See

conda config -h

更多选项。

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

Packages on conda-forge may be more up-to-date than those on the defaults channel There are packages on the conda-forge channel that aren't available from defaults You would prefer to use a dependency such as openblas (from conda-forge) instead of mkl (from defaults). 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). For reference, see the Conda Forge post on mixing channels.


有一些Python库不能通过简单的conda install安装,因为除非应用conda-forge,否则它们的通道不可用。根据我的经验,在查找不同的渠道源时,pip比conda更通用。 例如,如果你想安装python-constraint,你可以通过pip install来安装,但要通过**cond **来安装。您必须指定通道- conda-forge。

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

但不是

conda install python-constraint

conda-forge频道是您可以找到为conda构建的软件包,但尚未成为官方Anaconda发行版的一部分的地方。

一般来说,你可以使用它们中的任何一个。


Anaconda修改了他们的服务条款,这样“重度商业用户”就必须付费,这并不包括conda伪造频道。

The main channel is maintained by Anaconda, while conda-forge is maintained by the maintainers of the packages themselves. Each have their pros and cons. Packages on the main channel are usually compatible with one another, meaning you can install almost as many as you want, and you won't have dependency conflicts. On the other hand, packages on the conda-forge channel receive the updates much faster than the main channel since the maintainers themselves push the updates to the channel. From time to time, there are also patches done by Anaconda on packages available on the main channel which are not supported and done by the maintainers of the package, which can be good or bad, but definitely out of hands of the maintainers and not supported by them.

如果您不想为使用付费,您可能会希望坚持使用conda-forge,并且您可以接受pypi上可用的版本。如文件所述:

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

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

如果您已经安装了conda,并且希望删除默认通道,则可以使用

conda config --show channels

要看你的频道,并能使用

conda config --remove channels channel-name

删除一个通道。


根据我的经验,conda-forge频道提供了更多的软件包,而且它们也更新得更多。这就是为什么我使用它作为我的默认通道,可以这样做

conda config --add channels conda-forge
conda config --set channel_priority strict