Can I add a channel to a specific conda environment?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



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:


~/.condarc


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.


~/.condarc



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.





My experience has been that this is not possible (yet). What I do in these situations is remember to specify the channel to all install/update commands, for instance conda update -c conda-forge --all works well. Beware though that all the possible packages will be installed from conda-forge then.
– darthbith
Nov 15 '16 at 23:15



conda update -c conda-forge --all


conda-forge




3 Answers
3



Currently it is not possible to add a channel to a single conda environment. If you do not want to add a channel to the global ~/.condarc file, you should use the option to install a package from a specific channel:


~/.condarc


conda install <some-package> -c glotzer





This is no longer true. Per-environment .condarc files have been supported since conda 4.2.
– Christopher Barber
Aug 8 at 13:21



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


.condarc


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]


--env





This sounds perfect. Do you know if this has been added to the documentation? Could you add a link?
– Steven C. Howell
Aug 9 at 3:17






Just type conda config -h
– Christopher Barber
Aug 9 at 13:09


conda config -h



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:


environment.yml


conda


name: EnvironmentName
channels:
- conda-forge
- glotzer
dependencies:
- pip:
- tensorflow
- pandas=0.22.*



To use the environment, type


conda env create -f environment.yml
conda activate EnvironmentName



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


environment.yml


conda env update -f environment.yml
conda activate EnvironmentName





This is a helpful work around.
– Steven C. Howell
May 23 at 15:37





This doesn't answer the question. Furthermore the channels in the environment.yml file are only used to create the environment and do not get added to the default configuration of the environment (i.e. no .condarc file is created for the environment containing its channels), so installing additional packages will require manually specifying the channels on the command line.
– Christopher Barber
Aug 11 at 20:33



environment.yml


.condarc





I only ever create environments using an environment.yml file, and in a non-default environment, I never use conda install — I always update the environment file, then conda --env update. This way the environment file always represents the current state of the environment, which makes my environments 100% portable — the file contains all the info needed to recreate them.
– BallpointBen
Aug 11 at 20:37


environment.yml


conda install


conda --env update






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

Creating a leaderboard in HTML/JS