python - 如何使用 conda-forge 而不是 anaconda channel 获取 "conda update --all"安装?

标签 python anaconda conda-forge

当我运行 conda update --all 时,默认情况下会更新来自 anaconda channel 的包。我更喜欢默认使用 conda-forge channel ,因为这些软件包是最新的。

我该怎么做?

最佳答案

要默认使用 conda-forge channel ,conda-forge 的优先级应高于 defaults channel 。

检查~/.condarc

cat ~/.condarc

它会返回类似这样的内容

channels:
  - defaults
  - conda-forge
channel_priority: flexible

更改 ~/.condarc 的 channel 顺序,使 conda-forge 成为第一个 channel

channels:
 - conda-forge
 - defaults 
channel_priority: flexible

或者运行等效的命令行

conda config --add channels conda-forge
Warning: 'conda-forge' already in 'channels' list, moving to the top

下次运行 conda update --all 时,它将在 defaults channel 之前从 conda-forge channel 进行搜索。

Conda documentation解释 conda 如何从不同 channel 收集包。

附加

您应该考虑将channel_priority设置为strict,目前flexible是默认值。根据 conda 文档,strict 将成为下一个主要版本 conda 5.0 中的默认设置。

conda config --set channel_priority strict

要了解channel_priority的作用,请运行conda config --describe channel_priority

channel_priority (ChannelPriority)
Accepts values of 'strict', 'flexible', and 'disabled'. The default
value is 'flexible'. With strict channel priority, packages in lower
priority channels are not considered if a package with the same name
appears in a higher priority channel. With flexible channel priority,
the solver may reach into lower priority channels to fulfill
dependencies, rather than raising an unsatisfiable error. With channel
priority disabled, package version takes precedence, and the
configured priority of channels is used only to break ties. In
previous versions of conda, this parameter was configured as either
True or False. True is now an alias to 'flexible'.

channel_priority: flexible

另请注意,这是全局设置。引用this post ,如果这只适用于特定的 conda 环境,请激活 env 并在脚本中添加 --env

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

关于python - 如何使用 conda-forge 而不是 anaconda channel 获取 "conda update --all"安装?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73629200/

相关文章:

python - 同时使用多个双绞线套接字服务器

Python计算每个IP每小时的请求率

python - pandas 数组索引不足

python - 如何从 InlineFormset 中的图像字段获取图像 URL?

python - 根据另一个数组中的所有值查找一个数组的最近索引 - Python/NumPy

python - Linux 系统上的多个 Python 发行版

python - 尽管有新版本,Anaconda 不会更新 spyder

continuous-integration - 通过 conda-forge/conda-install 指定 conda 包的默认版本

conda - 如何安装 Bioconda 软件包

python - 防止conda自动降级python包