简体   繁体   中英

Why would one add a channel to a conda environment?

One can add channels (eg conda-forge) to conda via

conda config --add channels conda-forge

For completeness, since conda 4.2 one can add channels (eg conda-forge) to specific environments via

conda config --env --add channels conda-forge

( see also this post ).

I am wondering if there are any other considerations why one might want to add (or not) a channel to conda / a specific conda environment other than sheer convenience of installing packages without specifying -c conda-forge ?

Are there any advantages / disadvantages in adding channels?

It's mostly convenience - ie, the conda install command is sufficiently expressive to specify any channel prioritization. For example, one can specify the recommended Bioconda channel priorities manually at each install:

conda install -n metagenomics_env --override-channels -c conda-forge -c bioconda -c defaults kraken

but setting it on a per-env basis let's one set and forget

conda activate metagenomics_env
conda config --env --add channels defaults
conda config --env --add channels bioconda
conda config --env --add channels conda-forge
...
conda install -n metagenomics_env kraken

This can be quite helpful when one has a diversity of projects that aren't conducive to having a single, global channel prioritization.

One issue that one should be aware of is that running conda env export always results in exporting the global channel configuration. While build IDs are included in the environment.yml , and are usually sufficiently distinct to capture channel of origin, if the channel isn't in the global channels configuration, then the builds won't be found if the system recreating the env doesn't have that channel in their config.


Additional Uses

It is also worth emphasizing that the --env flag enables every config option to be set on an env-specific basis, not just channels. This can be useful for some edge cases, such as specifying a subdir constraint (eg, win-32 vs win-64 ) or enabling experimental features like pip_interop_enabled only in specific envs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM