228

Conda and conda-forge are both Python package managers. What is the appropriate choice when a package exists in both repositories? Django, for example, can be installed with either, but the difference between the two is several dependencies (conda-forge has many more). There is no explanation for these differences, not even a simple README.

Which one should be used? Conda or conda-forge? Does it matter?

  • 26
    "Conda and conda-forge are both Python package managers." I don't think that's true. I don't think those are even in the same category of thing. `conda` is a package manager and `conda-forge` is a channel. Maybe it was true when this question was asked? – endolith Jun 25 '19 at 20:32

5 Answers5

352

The short answer is that, in my experience generally, it doesn't matter which you use.

The long answer:

So conda-forge is an additional channel from which packages may be installed. In this sense, it is not any more special than the default channel, or any of the other hundreds (thousands?) of channels that people have posted packages to. You can add your own channel if you sign up at https://anaconda.org and upload your own Conda packages.

Here we need to make the distinction, which I think you're not clear about from your phrasing in the question, between conda, the cross-platform package manager, and conda-forge, the package channel. Anaconda Inc. (formerly Continuum IO), the main developers of the conda software, also maintain a separate channel of packages, which is the default when you type conda install packagename without changing any options.

There are three ways to change the options for channels. The first two are done every time you install a package and the last one is persistent. The first one is to specify a channel every time you install a package:

conda install -c some-channel packagename

Of course, the package has to exist on that channel. This way will install packagename and all its dependencies from some-channel. Alternately, you can specify:

conda install some-channel::packagename

The package still has to exist on some-channel, but now, only packagename will be pulled from some-channel. Any other packages that are needed to satisfy dependencies will be searched for from your default list of channels.

To see your channel configuration, you can write:

conda config --show channels

You can control the order that channels are searched with conda config. You can write:

conda config --add channels some-channel

to add the channel some-channel to the top of the channels configuration list. This gives some-channel the highest priority. Priority determines (in part) which channel is selected when more than one channel has a particular package. To add the channel to the end of the list and give it the lowest priority, type

conda config --append channels some-channel

If you would like to remove the channel that you added, you can do so by writing

conda config --remove channels some-channel

See

conda config -h

for more options.

With all of that said, there are four main reasons to use the conda-forge channel instead of the defaults channel maintained by Anaconda:

  1. Packages on conda-forge may be more up-to-date than those on the defaults channel
  2. There are packages on the conda-forge channel that aren't available from defaults
  3. You would prefer to use a dependency such as openblas (from conda-forge) instead of mkl (from defaults).
  4. If you are installing a package that requires a compiled library (e.g., a C extension or a wrapper around a C library), it may reduce the chance of incompatibilities if you install all of the packages in an environment from a single channel due to binary compatibility of the base C library (but this advice may be out of date/change in the future). For reference, see the Conda Forge post on mixing channels.
merv
  • 67,214
  • 13
  • 180
  • 245
darthbith
  • 18,484
  • 9
  • 60
  • 76
  • 2
    Thanks! I have two related questions: 1. how can I find out which channel is good to try and; 2. after I config on one channel, how can I reset it back to default? – Daniel Nov 11 '16 at 00:49
  • 1
    @Kenny To answer your first question, you should search for the package you want on https://anaconda.org and see which channels have the package. I edited the answer to answer your second question. However, I'd also note that if you want to install a single package from a channel, it is probably easier to use the `conda install -c some-channel packagename` way of writing the command – darthbith Nov 11 '16 at 13:37
  • this is great! Is there a comparison available between conda-forge and conda in terms of # of supported modules, freshness, coverage etc? – Rutger Hofste Apr 06 '18 at 10:21
  • 2
    Isn't `mkl` faster than `openblas`? – endolith Jul 28 '18 at 12:59
  • 6
    @endolith Maybe, but 1) possibly only on Intel processors and 2) it is not open source – darthbith Jul 28 '18 at 13:02
  • I'm currently working in with spatial GIS data and conda-forge has a lot, lot more packages (gdal, geopandas, fiona, shapely etc.) that are up to date with proper dependencies configured that aren't on the normal conda channel. The standard pip-install had multiple dependency issues. Based on this would definitely recommend conda-forge as the go-to channel. – Hansang May 21 '19 at 23:58
  • Thanks for the info about `conda-forge` using different dependencies with `mkl` and `openblas`! I – Matt Eding Nov 24 '19 at 20:41
47

Anaconda has changed their Terms of Service so that "heavy commercial users" would have to pay, which doesn't include conda-forge channel.

The main channel is maintained by Anaconda, while conda-forge is maintained by the maintainers of the packages themselves. Each have their pros and cons. Packages on the main channel are usually compatible with one another, meaning you can install almost as many as you want, and you won't have dependency conflicts. On the other hand, packages on the conda-forge channel receive the updates much faster than the main channel since the maintainers themselves push the updates to the channel. From time to time, there are also patches done by Anaconda on packages available on the main channel which are not supported and done by the maintainers of the package, which can be good or bad, but definitely out of hands of the maintainers and not supported by them.

You probably would want to stick to conda-forge if you don't want to pay for the usage and you would be okay with the versions available on pypi. As stated in the docs:

conda config --add channels conda-forge
conda config --set channel_priority strict
conda install <package-name>

You could also use miniforge which has conda-forge as the default channel, and supports ppc64le and aarch64 platforms as well as the other usual ones.

If you have conda installed and would like to remove the default channels, you can use

conda config --show channels

to see your channels, and can use

conda config --remove channels channel-name

to remove a channel.

adrin
  • 4,511
  • 3
  • 34
  • 50
  • 1
    Do you know for sure that using conda-forge as the default channel eliminates the terms of service violation? I have heard that because the base conda uses the default channel on installation it might still be a problem, thoughts? – user3358152 Sep 23 '20 at 14:59
  • That's a good point, and I'm not sure about it. If one wants to be safe, one can always fall back to `miniforge`. – adrin Sep 24 '20 at 11:31
  • @adrin is [Miniconda](https://docs.conda.io/en/latest/miniconda.html) free for commercial use also? – Yousef Saber Jan 09 '21 at 14:55
  • @YousefSaber I'm not sure about miniconda, but `conda` itself is BSD licensed and you can use it freely. – adrin Jan 10 '21 at 16:03
  • Can you also remove the conda channels? – lalala Jan 15 '21 at 14:28
  • The top answer above has also an answer for you @lalala – demokritos Jan 17 '21 at 08:16
  • 2
    pwang99 (the current Anaconda CEO, I believe) on Reddit confirmed that miniconda is a free alternative to Anaconda: https://www.reddit.com/r/Python/comments/lvr85n/i_want_to_use_python_commercially_for_free_is/gqiae2i?utm_source=share&utm_medium=web2x&context=3 – KBurchfiel Mar 11 '21 at 04:38
  • 1
    @YousefSaber Miniconda still sources from the default Anaconda Cloud channels, which fall under the ToS. You would need to update the channels as per this post, then update the packages to re-source from non-default channels. Or just start from Miniforge or one of its variants. – merv May 27 '21 at 21:00
  • @merv yeah I believe everything is clear now, Miniconda is free for commercial use, but using the default channel requires some license fees that's why I've changed the settings to use [Conda-forge](https://conda-forge.org/blog/posts/2020-11-20-anaconda-tos/) instead to avoid thos new TOS. – Yousef Saber Aug 26 '21 at 19:30
  • Are there drawbacks to mixing packages from the default channel and conda-forge? E.g. in terms of compatibility or something else? – Joooeey Apr 18 '23 at 12:46
  • @Joooeey you can always mix packages from different channels, that goes for the `main` and the `conda-forge` channels as well. – adrin Apr 24 '23 at 08:25
8

The conda-forge channel is where you can find packages that have been built for conda but yet to be part of the official Anaconda distribution.

Generally, you can use any of them.

Ashiq Imran
  • 2,077
  • 19
  • 17
0

In my experience the channel conda-forge provides more packages and they are also more up-to-date. That is why I use it as my default channel which can be done like so

conda config --add channels conda-forge
conda config --set channel_priority strict
ffrosch
  • 899
  • 6
  • 15
-5

There are some Python libraries that you cannot install with a simple conda install since their channel is not available unless you apply conda-forge. From my experience, pip is more generic to look into different channel sources than conda. For instance, if you want to install python-constraint you can do it via pip install but to install it via **cond **. you have to specify the channel - conda-forge.

conda install -c conda-forge python-constraint // works

but not

conda install python-constraint
ewalel
  • 1,932
  • 20
  • 25
  • 4
    Confusing answer. pip installing takes the package outside of conda's own package management and dependency verification, which means you need to manage it (and potentially its dependencies) manually and that commands such as `conda update --all` will not update the pip installed package – Jean Monet Jun 20 '20 at 10:09
  • 7
    This answer gives bad advice. It is bad practice to interleave conda and pip commands in the same environment. Use conda install for all packages exclusively, unless a particular python package is not available in conda format. Then use pip as a last resort, because pip will NOT add the package to the conda package index for that environment. Using conda, then pip, then conda, then pip, then conda, etc. to build an environment will eventually give a corrupted conda environment index. – Rich Lysakowski PhD Aug 09 '20 at 06:21
  • @RichLysakowskiPhD Where did the answer suggested to interleave conda and pip commands in the same environment? -JeanMonet: The answer is not favoring one over the other. It is about how specifying the channel 'conda-forge' is sometimes helpful. – ewalel Aug 27 '20 at 17:25
  • 1
    The original poster is asking about using conda or conda-forge, so why are you providing an answer about the `pip` package manager? @Jean Monet also touches upon the pitfall of using pip and conda together, because conda will not update packages which are referenced only in the local pip package index and not in the conda package index. If you start with conda for environment and package management, then stick with it. Use pip packages as a last resort and last step when working with conda environments. – Rich Lysakowski PhD Aug 29 '20 at 14:21
  • 1
    Yes, the original question focused on using conda or conda-forge. And clearly, the answer I provided with example inside the code block targets the question. Here is my understanding, conda, conda-forge, and pip all are Python package managers. So what is the oversight of discussing pip as an option while answering the original question? The answer didn't suggest to use them together. For that matter, using them together is not a sinful act, as long as the user knows how to use them. However, I agree on the downsides described by Jean. – ewalel Aug 29 '20 at 15:15