Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Conda: How to ignore if a conda channel is not reachable? Ignore UnavailableInvalidChannel?

Tags:

python

conda

The situation

At work we have a private conda channel in our network that is used for some internal packages. Since I do not want to type the channel location every time I install something via conda install, I added it to condas default channels in .condarc.

The problem

Obviously the channel is only available inside my company's network. When I am outside the network and want to install for example numpy (so a normal package available on the conda default channel) I get the following error because the private channel is not available:

conda.exceptions.UnavailableInvalidChannel: The channel is not accessible or is invalid.
  channel name: privateChannel
  channel url: file://address/in/companys/network
  error code: 404

independent from what package I want to install!

What I am looking for

An option to tell conda to ignore the UnavailableInvalidChannel error or something similar that solves my problem. Because I do not want to edit my .condarc every time I switch to another network...

Usually I am aware of, if I am going to install an internal package that I need the company's channel for so I would not mind if conda skips the internal channel silently or with a warning for everything else if it is not available. I just do not want conda to abort everything if it is not available.


Another small related question: Is there a way to define channel aliases? I am aware of channel-alias but that just changes the default channel prefix.

like image 570
NemesisMF Avatar asked Nov 07 '22 10:11

NemesisMF


1 Answers

Solution

More or less by accident I found the answer to my own question recently and do not want to keep it by myself.

To prevent conda to fail when a channel is not available during install/update of packages from other available channels you have to set the following parameter in your .condarc file:

allow_non_channel_urls = True

Or instead of editing your .condarc directly, you can type in your terminal:

conda config --set allow_non_channel_urls True

The parameter with the not very intuitive name allow_non_channel_urls is not explained in the conda docs about using the .condarc conda configuration file. But you can find it in their full .condarc example here and nowhere else.

What does it do?

The official explanation is "Warn, but do not fail, when conda detects a channel url is not a valid channel". This means for example, that if the channel URL is simply not reachable from the network you are currently using (maybe you are outside of your companies network) conda will just print a warning instead of abort installing packages. This is exactly what I wanted!

The warning can look quite excessive because it is printed for every architecture (linux-32, win-64, osx-64, noarch, etc.)

Note

Conda will still fail with an error if your package is not found on the available channels. But in that case you want conda to fail.

like image 195
NemesisMF Avatar answered Nov 14 '22 21:11

NemesisMF