Skip to main content

Conda Usage Guide

Conda is an open-source package management and environment management system that can quickly install, run, and update packages and their dependencies. It was originally designed for the Python scientific computing package Anaconda, but is now widely used for various programming languages and applications.

Installing Conda​

Check the Latest Version​

Anaconda: Visit Anaconda Download, copy the download link

Miniconda: Visit Miniconda Documentation, copy the download link

Download Anaconda or Miniconda​

You can choose to install Anaconda or Miniconda. Anaconda includes a large number of scientific computing packages, while Miniconda only includes Conda and Python, suitable for users who need a smaller installation package.

  1. Download Anaconda:

    wget https://repo.anaconda.com/archive/Anaconda3-2024.02-1-Linux-x86_64.sh
  2. Download Miniconda:

    wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh

Install Anaconda or Miniconda​

  1. Run the installation script:

    bash Anaconda3-2023.03-Linux-x86_64.sh

    Or

    bash Miniconda3-latest-Linux-x86_64.sh

    Note: For non-interactive installation, add -b after the command.

  2. Follow the prompts to complete the installation process.

  3. After installation, activate Conda:

    source ~/.bashrc

    Or

    source ~/.bash_profile

Verify Installation​

Verify that Conda is installed successfully:

conda --version

Miniconda Installation Example​

apt-get update && apt-get install -y wget
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh -b
export PATH=/root/miniconda3/bin:$PATH

Basic Commands​

Check Conda Version​

conda --version

Update Conda​

conda update conda

View Help​

conda --help

Managing Environments​

Create a New Environment​

conda create --name myenv

You can specify the Python version:

conda create --name myenv python=3.8

Activate Environment​

conda activate myenv

Deactivate Environment​

conda deactivate

List All Environments​

conda env list

Or

conda info --envs

Remove Environment​

conda remove --name myenv --all

Managing Packages​

Install Package​

conda install package_name

Specify version:

conda install package_name=2.1.0

Remove Package​

conda remove package_name

Update Package​

conda update package_name

List Installed Packages​

conda list

Search Package​

conda search package_name

Updating Conda​

Keeping Conda up to date is key to ensuring its stability and security.

Update Conda Itself​

conda update conda

Update Anaconda (if using Anaconda)​

conda update anaconda

Common Issues​

Conda Command Not Found​

Make sure the Conda path has been added to your shell configuration file (such as .bashrc or .bash_profile). Add the following:

export PATH="$HOME/miniconda3/bin:$PATH"

Then reload the configuration file:

source ~/.bashrc

Or

source ~/.bash_profile

Environment Dependency Conflicts​

If you encounter environment dependency conflicts, try using the conda-forge channel:

conda install -c conda-forge package_name

Conda Environment Activation Failure​

Make sure the Conda initialization script is correctly configured. You can reinitialize:

conda init

Then restart your shell.