Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I add a channel to a specific conda environment?

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.

like image 567
Steven C. Howell Avatar asked Nov 15 '16 17:11

Steven C. Howell


People also ask

What are conda environment channels?

 Conda channels are the locations where packages are stored. They serve as the base for hosting and managing packages. Conda packages are downloaded from remote channels, which are URLs to directories containing conda packages.


2 Answers

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]

like image 139
Christopher Barber Avatar answered Sep 21 '22 21:09

Christopher Barber


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 
like image 22
Steven C. Howell Avatar answered Sep 23 '22 21:09

Steven C. Howell