Home Anaconda Distribution Enable Conda-forge Channel For Conda Package Manager

Enable Conda-forge Channel For Conda Package Manager

By sk
Published: Updated: 47.6K views

This guide explains what is conda-forge channel, how to install packages from conda-forge and finally how to permanently enable conda-forge channel for conda package manager from commandline as well as from Anaconda Navigator GUI in Linux.

What is conda-forge?

By default, the conda package manager installs packages from the defaults channel. All packages in the defaults channel are thoroughly tested and maintained by the Conda team from Anaconda, Inc.

Apart from the official defaults channel, there are some third-party channels available for hosting and managing packages. One such channel is conda-forge.

Conda-forge is community-led channel that provides latest conda packages for a wide-range of software.

The defaults channel may not always contain all packages. There could be some missing packages or it may contain outdated packages. The conda-forge community tackles these issues by maintaining up-to-date packages with the help of thousands of contributors.

Conda-forge project is financially supported by NumFOCUS, a non-profit dedicated to support open source scientific computing community.

Install packages from conda-forge channel

It is possible to install packages from a specific channel without adding it in our system. Let us see an example.

It is recommended to always install packages from conda-forge channel in a new environment instead of the default base environment.

The following command will create a new environment named testapp and install pandas along with its supporting packages in the testapp environment:

$ conda create --channel conda-forge --name testapp pandas

Or,

$ conda create -c conda-forge -n testapp pandas
Install packages from conda-forge channel
Install packages from conda-forge channel

Here, -c (--channel) flag is used to explicitly mention the channel name i.e. conda-forge in our case.

Activate the newly created "testapp" environment:

$ conda activate testapp

Check the origin of all installed packages in the environment:

$ conda list
 packages in environment at /home/sk/anaconda3/envs/testapp:
 #
 Name                    Version                   Build  Channel
 _libgcc_mutex             0.1                 conda_forge    conda-forge
 _openmp_mutex             4.5                       1_gnu    conda-forge
 ca-certificates           2020.12.5            ha878542_0    conda-forge
 certifi                   2020.12.5        py39hf3d152e_1    conda-forge
 ld_impl_linux-64          2.35.1               hea4e1c9_2    conda-forge
 libblas                   3.9.0                8_openblas    conda-forge
 libcblas                  3.9.0                8_openblas    conda-forge
 libffi                    3.3                  h58526e2_2    conda-forge
 libgcc-ng                 9.3.0               h2828fa1_18    conda-forge
 libgfortran-ng            9.3.0               hff62375_18    conda-forge
 libgfortran5              9.3.0               hff62375_18    conda-forge
 libgomp                   9.3.0               h2828fa1_18    conda-forge
 liblapack                 3.9.0                8_openblas    conda-forge
 libopenblas               0.3.12          pthreads_h4812303_1    conda-forge
 libstdcxx-ng              9.3.0               h6de172a_18    conda-forge
 ncurses                   6.2                  h58526e2_4    conda-forge
 numpy                     1.20.1           py39hdbf815f_0    conda-forge
 openssl                   1.1.1j               h7f98852_0    conda-forge
 pandas                    1.2.2            py39hde0f152_0    conda-forge
 pip                       21.0.1             pyhd8ed1ab_0    conda-forge
 python                    3.9.1           hffdb5ce_5_cpython    conda-forge
 python-dateutil           2.8.1                      py_0    conda-forge
 python_abi                3.9                      1_cp39    conda-forge
 pytz                      2021.1             pyhd8ed1ab_0    conda-forge
 readline                  8.0                  he28a2e2_2    conda-forge
 setuptools                49.6.0           py39hf3d152e_3    conda-forge
 six                       1.15.0             pyh9f0ad1d_0    conda-forge
 sqlite                    3.34.0               h74cdb3f_0    conda-forge
 tk                        8.6.10               h21135ba_1    conda-forge
 tzdata                    2021a                he74cb21_0    conda-forge
 wheel                     0.36.2             pyhd3deb0d_0    conda-forge
 xz                        5.2.5                h516909a_1    conda-forge
 zlib                      1.2.11            h516909a_1010    conda-forge
List installed packages in a conda environment
List installed packages in a conda environment

As you see in the above output, all packages are installed from the conda-forge repository.

If you don't want to create new environment but install packages in the existing active environment, run:

$ conda install --channel conda-forge pandas

This command will install pandas package from the conda-forge channel in the existing environment.

Let us verify if the conda-forge channel is added by using nay one of the following methods:

$ conda info

This command displays the details of currently active conda environment, including the channels.

[...]
           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
[...]

If you want to show only the channels, use this command:

$ conda config --show channels

Sample output:

channels:
  - defaults

To show the default channels only, run:

$ conda config --show default_channels

Sample output:

default_channels:
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
Show active channels in conda environment
Show active channels in conda environment

As you see in the above outputs, conda-forge is not added. We've only installed the packages from the conda-forge channel, but we didn't add it yet.

Now let us go ahead and add or enable conda-forge channel permanently.

Enable conda-forge channel for conda package manager in Linux

As stated already, we can add or enable conda-forge channel either from commadline or from Anaconda Navigator graphical user interface. First, we will see the commanline way.

1. Add conda-forge channel from commandline

To enable conda-forge channel, run the following command from the Terminal:

$ conda config --add channels conda-forge

As stated earlier, conda installs the packages from the defaults channel unless you explicitly tell it to install packages from a specific channel.

To install packages always from conda-forge, set higher priority to conda-forge channel using command:

$ conda config --set channel_priority strict

Here, the channel_priority strict option will place conda-forge channel on top of defaults channel and ensure that all the dependencies will come from the conda-forge channel unless they exist only on defaults.

Check if conda-forge channel is added using command:

$ conda config --show channels
channels:
  - conda-forge
  - defaults

Did you notice? conda-forge is placed on the top of defaults channel.

Now you can normally install any package on your environment without explicitly mentioning the channel like below:

$ conda install pandas

The package will always be downloaded from the conda-forge channel.

Install packages from conda-forge in Linux
Install packages from conda-forge in Linux

Just in case, if the package or its dependencies are not available in conda-forge, they will be downloaded from defaults channel.

Like I already mentioned, it is recommended to always install packages on a new environment instead of the default base environment. This way you can avoid package conflicts and maintain a clean base environment.

Adding channels via command line is not a big deal. However, some of you prefer the graphical way to get things done. The following section explains how to enable conda-forge channel from Anaconda Navigator GUI.

2. Add conda-forge channel from Anaconda Navigator

Launch Anaconda Navigator using command:

$ anaconda-navigator

Click Channels button:

Click Channels button in Anaconda Navigator GUI
Click Channels button in Anaconda Navigator GUI

Click Add button:

Click Add to add new channel
Click Add to add new channel

Enter the conda-forge channel URL - https://conda.anaconda.org/conda-forge/. Press ENTER key to update the Channel list.

Enter the conda-forge channel URL
Enter the conda-forge channel URL

Finally click Update channels button to enable conda-forge channel.

Resource:

You May Also Like

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

This website uses cookies to improve your experience. By using this site, we will assume that you're OK with it. Accept Read More