(Mini) Conda on Linux

Conda logo

Conda is an open-source package manager and environment management system that runs on Windows, macOS, and Linux. Miniconda is a minimal version of Conda that includes only Conda and its dependencies. This tool allows you to create isolated environments to manage different versions of packages and software dependencies without conflicts.

📥 Installing Conda on Linux

To install Conda on Linux, follow these steps:

  1. Download the Miniconda installer from the official website:
    wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
  2. Run the installer:
    bash Miniconda3-latest-Linux-x86_64.sh
  3. Follow the on-screen instructions and accept the license agreement. After the installation is complete, close and reopen the terminal or run:
    source ~/.bashrc

🌐 Managing Environments

Conda environments allow you to create and manage different development environments. Here are some essential commands:

📦 Managing Packages

Conda contains a package manager that simplifies package installation and management. **N.B.** Conda is compatible with pip, so you can use both package managers depending on your needs. pip is out of the scope of this guide. If you want to know more about it, check the official documentation. The following are some common Conda package management commands:

📋 Complete Example: Creating and Managing an Environment with pip

Below is an example of how to create a Conda environment, activate it, and install packages using pip:

  1. Create a new environment called example_environment with Python 3.10:
    conda create --name example_environment python=3.10
  2. Activate the newly created environment:
    conda activate example_environment

    The terminal prompt should change to:

    (example_environment) user@hostname:~$
  3. Install packages using pip (e.g., numpy and pandas):
    pip install numpy pandas
  4. Verify that the packages were installed correctly:
    python -c "import numpy; import pandas; print('Numpy and Pandas installed correctly')" 
  5. Deactivate the environment when you are done working:
    conda deactivate

🔍 Useful Commands

Here are some useful Conda commands for various operations: