Can I add a channel to a specific conda environment?

Steven C. Howell picture Steven C. Howell · Nov 15, 2016 · Viewed 31.8k times · Source

I want to add a conda channel to a specific conda environment but when I use

conda config --add channels glotzer

that channel is now available from all my conda environments. In addition to testing an install from another environment, the ~/.condarc file has the following:

channels:
  - glotzer
  - defaults

How would I configure conda so the channel is only available from a specific environment?

I did find in the channel documentation that for conda >= 4.1.0, putting channels at the bottom of the ~/.condarc will prevent added channels from overiding the core package set.

By default conda now prefers packages from a higher priority channel over any version from a lower priority channel. Therefore you can now safely put channels at the bottom of your channel list to provide additional packages that are not in the default channels, and still be confident that these channels will not override the core package set.

I expect this will prevent most problems, except when in one environment you do want the package added through a channel to override a core package.

Answer

Christopher Barber picture Christopher Barber · Aug 8, 2018

As of conda 4.2, environment-specific .condarc files are supported and you can write:

conda config --env --add channels glotzer

to add the channel to the configuration for the active environment.

[Not sure whether --env flag was added in 4.2. Answer based on conda 4.5.9]