Search code examples
pythonanaconda

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


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.


Solution

  • 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.