3.5. Conda packages#

You can use the Conda package manager to create isolated environments and install software available from Anaconda Cloud repositories.

These environments can be activated, deactivated and removed when they are no longer needed.

3.5.1. Requirements#


You should not add sudo in the commands below.

This method only installs files in your home directory and so does not require administrator privileges.

3.5.2. Installing Conda#

A minimal installation of Conda can be setup by installing Miniconda. You will need to download and run the Miniconda installer following the steps below.

1. Downloading Miniconda#

To download the correct version of Miniconda:

  1. Open the Conda downloads page in a browser.

  2. Navigate to the Linux installers section (Fig. 63)

    Miniconda installers for Linux

    Fig. 63 Miniconda installers for Linux#

  3. Click on the download link corresponding to:

    Python 3.8 — Miniconda3 Linux 64-bit

    Save the file. It will be saved as:



    You can verify the file’s SHA256 checksum to ensure it has been downloaded correctly. How?

2. Running the installer#

Run the installer using the bash command:

bash Miniconda3-latest-Linux-x86_64.sh

This will print a welcome message:

Welcome to Miniconda3 py38_4.8.3

In order to continue the installation process, please
review the license agreement.
Please, press ENTER to continue

3. Reviewing licence agreement#

Press the ENTER key to view the licence agreement. Scroll down to read the licence. Towards the end, you will notice a prompt:

Do you accept the license terms? [yes|no]
[no] >>> yes

You will need to type yes to accept the agreement and then press the ENTER key to proceed.

4. Confirming Miniconda install location#

Next, you will be asked to provide a path to install Miniconda.

Miniconda3 will now be installed into this location:

  - Press ENTER to confirm the location
  - Press CTRL-C to abort the installation
  - Or specify a different location below

[/home/user/miniconda3] >>>

Press ENTER here to accept the default value.

Installation will now proceed. When complete, you will notice a prompt asking if you would like to initialize Miniconda 3.

Do you wish the installer to initialize Miniconda3
by running conda init? [yes|no]
[no] >>> yes

Type yes and then press the ENTER key. This will add the conda command to your $PATH.

As a result of this configuration, Conda base environment will be activated automatically when you open a terminal session. This can be disabled in the next step. Why?

5. Disabling auto-activation of base environment#

Open a new terminal. Your shell prompt should now appear like the following:

(base) user@cookbook:~$

The (base) label at the beginning of the prompt, indicates that Conda base environment is now active.

To disable this behaviour, so you can activate the environment manually when you need it, run the following command:

conda config --set auto_activate_base false

6. Setting up channels#

Channels provide additional software for Conda.

Conda’s configuration includes a defaults channel. The bioconda and conda-forge channels can also be added to access an even larger collection of software. The bioconda channel, for example, provides over 7000 packages of Bioinformatics software.

To add these channels to your configuration, you can run the commands below.


You will need to run these commands in the same order as given below.

conda config --add channels defaults
conda config --add channels bioconda
conda config --add channels conda-forge

Installation and configuration of Conda is now complete.

You can now start using Conda to create environments and install packages from repositories.

3.5.3. Using Conda#

In this short guide on using Conda, I will show you how to:

  1. Create an environment

  2. Activate the environment

  3. Search, install and use packages — using the NCBI BLAST+ program as an example

  4. Remove an environment when you no longer need it


A cheat sheet with commonly used commands for working with Conda is available from the project’s website.

Creating an environment#

To create an environment, use the conda create command with the -n option, followed by a name for the environment — blast in this example:

conda create -n blast

Activating an environment#

You can get a list of all environments using the command:

conda envs list

To activate an environment, use the conda activate command with the name of the environment:

conda activate blast

Searching, installing and using Packages#

To search and install packages:

  1. First, activate the environment, if you haven’t done so already.

    To demonstrate, I will activate the blast environment created earlier:

    conda activate blast
  2. To search for packages, open Anaconda.org in a browser.

    Type your search term in the Search Packages field and press the ENTER key (Fig. 64).

    Searching for packages on Anaconda cloud

    Fig. 64 Searching for a package on Anaconda.org#

    Alternatively, you can use the conda search command:

    conda search blast

    This will output matching packages:

    Loading channels: done
    # Name   Version           Build  Channel
    blast     2.2.31               1  bioconda
    blast      2.9.0 pl526he19e7b1_7  bioconda
    blast     2.10.1 pl526he19e7b1_2  bioconda
  3. To install the package, use the conda install command with the name and version number of the package.


    You will need to use the highest version number of the program, obtained from search results. Otherwise, an older version might get installed.

    conda install blast==2.10.1
  4. Once installed, you can start using programs included with the package, for example:

    (blast) user@cookbook:~$ blastn -version


    blastn: 2.10.1+
     Package: blast 2.10.1, build Oct 14 2020 11:36:30

Deactivating an environment#

When your work is complete, you can deactivate an environment. To do so, use the command:

conda deactivate

Your shell prompt will change to its default state i.e., without the name of the Conda environment — (blast) in this case.

Removing an environment#

To remove an environment, when you no longer need it, use the command:

conda remove -n blast --all

Here -n is used to indicate the name of environment you would like to remove and --all removes all packages installed in that environment.

3.5.4. Notes#

How to verify the installer’s SHA256 checksum#

  1. Navigate to the folder containing the installer file — Miniconda3-latest-Linux-x86_64.sh:

    cd Downloads
  2. Use the sha256sum command to verify the SHA256 checksum of the file:

    sha256sum Miniconda3-latest-Linux-x86_64.sh


    879457af6a0bf5b34b48c12de31d4df0ee2f06a8e68768e5758c3293b2daf688  Miniconda3-latest-Linux-x86_64.sh

The output of the sha256sum command should match the value listed on the downloads page.

Why disable auto-activation of base environment?#

If you are installing packages using other methods, for example Installing a Python package from PyPI, there is a possibility that you might accidentally install the package in Conda base environment instead of the intended location.

Even if you disable auto-activation of the base environment, you can activate it using the conda activate base command, when you need it.