SoFunction
Updated on 2025-04-11

Detailed Guide to Installing Conda on CentOS System

Preface

Conda is an open source package management system and environment management system, widely used in the fields of data science and machine learning. This article will introduce in detail how to install Conda on CentOS system to help you quickly build a development environment.

Preparation

Before starting the installation, make sure your CentOS system meets the following conditions:

  • Connected to the Internet
  • Have sudo permissions
  • The system has been installed wget and bash

Installation steps

1. Download the Miniconda installation script

wget /miniconda/Miniconda3-latest-Linux-x86_64.sh

2. Run the installation script

bash Miniconda3-latest-Linux-x86_64.sh

3. Read and agree to the license agreement

During the installation process, you will see the license agreement. Follow the prompts to enter yes to agree to the agreement.

4. Select the installation location

You will be asked where to install Miniconda. The default location is usually the user's home directory, such as ~/miniconda3. You can press Enter to accept the default location, or specify another path.

5. Initialize Conda

The installation script asks whether to initialize Miniconda3. It is recommended to select yes, which will automatically add Conda to your PATH.

6. Activate the installation

source ~/.bashrc

7. Verify the installation

conda --version

Common Conda commands

Create a new environment: conda create --name myenv python=3.8

Activate environment: conda activate myenv

View existing environment: conda env list

Installation package: conda install numpy

Things to note

It is recommended to update conda regularly.

Use conda update --all command with caution

Specify the Python version when creating a virtual environment

Advanced Usage

Create different Python version environments

conda create -n py38 python=3.8
conda create -n py39 python=3.9
conda create -n py310 python=3.10

View dependency tree

conda list --explicit

Resolve dependency conflicts

conda install --no-deps packagename

Install Mamba

conda install -c conda-forge mamba

Use Mamba instead of Conda

mamba create -n fastenv python=3.9 numpy pandas

Add Tsinghua mirror

conda config --add channels /anaconda/pkgs/main/
conda config --add channels /anaconda/pkgs/free/

Export the complete environment

conda env export > 

Create an environment from a YAML file

conda env create -f 

Cross-platform environment export

conda env export --from-history > 

Disable automatic activation of base environment

conda config --set auto_activate_base false

Set the number of concurrent downloads

conda config --set download_threads 5

Configure cache directory

conda config --set pkgs_dirs /path/to/conda/packages

Dockerfile example

FROM continuumio/miniconda3

# Copy the environment fileCOPY  /tmp/
RUN conda env create -f /tmp/

Using Conda in Google Colab

!pip install conda

Manage your environment in Jupyter Lab

!conda install -c conda-forge jupyterlab

Check the environment status

conda info
conda list
conda doctor

Clean up unused packages and caches

conda clean -a

GitHub Actions Example

name: Conda Environment

on: [push]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - uses: conda-incubator/setup-miniconda@v2
      with:
        auto-update-conda: true
        python-version: 3.9
    - run: conda env create -f 
    - run: conda run -n myenv pytest

Safety advice

Conda and packages are updated regularly

Isolate project dependencies using virtual environment

Avoid installing packages directly in the base environment

Update with --no-pin with caution

Common Traps and Solutions

Dependency conflict handling

Use conda list --revisions backtracking

Create a new environment instead of modifying an existing environment

Priority to using conda-forge channels

Learning Resources

  • Conda official documentation
  • Anaconda Knowledge Base
  • Real Python Conda Tutorial

Conclusion

Conda is not only a package manager, but also an infrastructure for modern Python development. Mastering its advanced usage will greatly improve your development efficiency and project management capabilities.

How to use

Copy the above into a text file.

Save the file as conda_install_guide.md.

Use the Markdown editor (such as VS Code, Typora) or upload directly to a Markdown-enabled platform (such as GitHub) to view the results.

This is the article about this detailed guide on installing Conda on CentOS system. For more related content on CentOS installation, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!