How to remove channels in Conda?

Viewed 7257

How do you remove a channel, or at least instruct Conda to not abort if one of the channel URLs is down?

I was testing a buggy tool, which provided a Conda repo at https://www.idiap.ch/software/bob/conda/linux-64, but now that repo is offline, and now all calls to conda create --prefix=./cenv -y python=3.7 fail with the message:

Collecting package metadata (current_repodata.json): failed

CondaHTTPError: HTTP 503 SERVICE UNAVAILABLE for url <https://www.idiap.ch/software/bob/conda/linux-64/current_repodata.json>
Elapsed: 00:02.470723

A remote server error occurred when trying to retrieve this URL.

A 500-type error (e.g. 500, 501, 502, 503, etc.) indicates the server failed to
fulfill a valid request.  The problem may be spurious, and will resolve itself if you
try your request again.  If the problem persists, consider notifying the maintainer
of the remote server.

I'm not using this channel in my create command, so I don't know why Conda fails rather than ignore it. How do I allow Conda to continue or purge the channel?

I tried removing the channel by running:

conda config --remove channels https://www.idiap.ch/software/bob/conda

outputs the error:

CondaKeyError: 'channels': 'https://www.idiap.ch/software/bob/conda' is not in the 'channels' key of the config file

Edit: My conda info is:

     active environment : None
            shell level : 0
       user config file : /home/myuser/.condarc
 populated config files : /home/myuser/miniconda3/.condarc
                          /home/myuser/.condarc
          conda version : 4.7.12
    conda-build version : not installed
         python version : 3.7.3.final.0
       virtual packages : 
       base environment : /home/myuser/miniconda3  (writable)
           channel URLs : https://repo.anaconda.com/pkgs/main/linux-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/linux-64
                          https://repo.anaconda.com/pkgs/r/noarch
                          https://www.idiap.ch/software/bob/conda/linux-64
                          https://www.idiap.ch/software/bob/conda/noarch
          package cache : /home/myuser/miniconda3/pkgs
                          /home/myuser/.conda/pkgs
       envs directories : /home/myuser/miniconda3/envs
                          /home/myuser/.conda/envs
               platform : linux-64
             user-agent : conda/4.7.12 requests/2.22.0 CPython/3.7.3 Linux/4.15.0-64-generic ubuntu/18.04.3 glibc/2.27
                UID:GID : 1000:1000
             netrc file : None
           offline mode : False

Running either:

conda config --remove channels https://www.idiap.ch/software/bob/conda/linux-64
conda config --remove channels https://www.idiap.ch/software/bob/conda/noarch

outputs the error:

CondaKeyError: 'channels': 'https://www.idiap.ch/software/bob/conda/<name>' is not in the 'channels' key of the config file

These ire the contents of my .condarc:

$ cat ~/.condarc 
show_channel_urls: true
auto_activate_base: false
channels:
  - defaults
2 Answers
conda config --remove channels https://www.idiap.ch/software/bob/conda

works in my test.

Another way is to open .condarc files under your $HOME directory, and comment out the corresponding channel line.

As far as I know, conda differentiates between channel names and channel URLs. I.e. conda info will output something like:

           channel URLs : https://repo.anaconda.com/pkgs/main/win-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/win-64
                          https://repo.anaconda.com/pkgs/r/noarch
                          https://repo.anaconda.com/pkgs/msys2/win-64
                          https://repo.anaconda.com/pkgs/msys2/noarch

whereas conda config --show channels will output

channels:
  - defaults

I think you have to remove channels by their name, not by their URL.

Also in your home directory there should be a file called .condarc which contains all the user's custom settings, including channels. You could just open that file with a text editor and delete the channel from there.

And lastly there is the flag --override-channels which ignores the default channel as well as all channels set in your .condarc, meaning with this flag you have to manually specify the channels you want to use in your conda command.

Related