How do I completely purge and disable the default channel in Anaconda and switch to conda-forge?

Question:

Is there a way to completely purge and disable the defaults channel in Anaconda and switch to conda-forge? The reason is that Anaconda term of service limits the use of its repository to non-commercial activities. Switching to conda-forge avoids the issue.

Asked By: xuhdev

||

Answers:

Typically, it should be sufficient to remove it from the channels configuration option, which corresponds to the user-level configuration file (~/.condarc). This could just be defaults, but check to see if you also need to remove anaconda, main, r, pro, or other subchannels of defaults.

# check what is currently set
conda config --show channels

# remove what you find 
conda config --remove channels defaults

# add conda-forge
conda config --add channels conda-forge

If this is not sufficient, one can use conda config --show-sources (as suggested by @CorneliusRoemer) to list the locations whence Conda is loading configuration settings (.condarc files, environment variables), as well as the content of each source. This should help in tracking down any atypical specifications of unwanted channels.

Alternatively, you may consider installing a Miniforge base (or a variant), which only includes conda-forge channel by default.


nodefaults option

Mentioned in the Conda docs is a nodefaults channel option for overriding channel settings. For example, this is useful for YAML files to prevent users with defaults in the .condarc from using it during environment creation. Example,

YAML Snippet

channels:
  - conda-forge
  - nodefaults

Note that this only works with Conda YAML files. The code is specific to the conda env subcommand and directs the solver to skip loading additional channels from the configuration context. It should also not be exonFor conda create or conda install commands, there is the --override-channels argument with equivalent functionality.

Answered By: merv
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.