Can I add a channel to a specific conda environment? Can I add a channel to a specific conda environment? python python

Can I add a channel to a specific conda environment?


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]


Update

As of Jan 2017, it was not possible to add a channel to a single conda environment. As of Dec 2020, this is now possible as described in Christopher Barber's answer.


Alternative

If you instead want to install a package from a specific channel but do not want to add that channel to the global ~/.condarc file, you should use the option to install a package from a specific channel:

conda install <some-package> -c glotzer


You can create an environment.yml file containing the specification of your conda environment. The full docs are here, but the basic setup is as follows:

name: EnvironmentNamechannels:    - conda-forge    - glotzerdependencies:    - pip:        - tensorflow    - pandas=0.22.*

To use the environment, type

conda env create -f environment.ymlconda activate EnvironmentName

To update the environment when environment.yml is changed or packages are updated,

conda env update -f environment.ymlconda activate EnvironmentName