How to Install Anaconda on CentOS
In this article
This guide walks you through installing Anaconda, a free and open-source distribution of Python and R for scientific computing and data science, on a CentOS system. By the end, you'll have a working Anaconda installation with the conda package manager ready to use. You'll need a CentOS machine (7 or 8, or similar like Rocky Linux or AlmaLinux) with an internet connection and a user account with sudo privileges.
What You'll Need
- A CentOS system (7, 8, or 9) with internet access.
- A user account with
sudoprivileges (or root access). - At least 3 GB of free disk space (Anaconda itself is about 2.5 GB).
- Basic familiarity with the Linux command line.
Step-by-Step
- Update your system (recommended)
Open a terminal and run:
or if using CentOS 8/9 with dnf:sudo yum update -y
This ensures your system packages are current and reduces potential dependency conflicts.sudo dnf update -y - Download the Anaconda installer
Visit the official Anaconda download page (anaconda.com/download) to get the latest Linux installer script. Alternatively, usewgetin the terminal. As of this writing, the latest version is Anaconda 2024.10, but replace the version number with the current one.
If you're on a different architecture, adjust the filename accordingly.cd /tmp wget https://repo.anaconda.com/archive/Anaconda3-2024.10-1-Linux-x86_64.sh - Verify the installer's integrity (optional but recommended)
Check the SHA-256 checksum against the one posted on the Anaconda website:
Compare the output with the hash listed on the download page. If they don't match, do not proceed; download again.sha256sum Anaconda3-2024.10-1-Linux-x86_64.sh - Run the installer
Execute the script with bash:
You'll be prompted to press Enter to continue, then to review the license agreement (press 'q' to skip to the end, then type 'yes' to accept).bash Anaconda3-2024.10-1-Linux-x86_64.sh - Choose the installation location
The installer will ask for the installation directory. The default is$HOME/anaconda3(e.g.,/home/username/anaconda3). Press Enter to accept the default, or type a custom path. Make sure the directory is writable by your user. - Add Anaconda to your PATH
The installer asks: "Do you wish the installer to initialize Anaconda3 by running conda init?" Typeyes. This adds the necessary lines to your~/.bashrcfile so thatcondais available every time you open a new terminal. - Activate the installation
After the installer finishes, close and reopen your terminal, or source your bashrc file:
You should now seesource ~/.bashrc(base)in your command prompt, indicating the base conda environment is active. - Verify the installation
Run the following commands to confirm everything works:
Theconda --version python --versioncondacommand should output its version, andpythonshould show the Python version bundled with Anaconda (e.g., Python 3.12.x). - Update conda (optional)
It's good practice to update conda to the latest version:
Answer 'y' when prompted.conda update conda
Common Mistakes
- Installing as root – While possible, it's not recommended because Anaconda's package management can conflict with system packages. Install as a regular user.
- Not running
conda init– If you type 'no' when asked about initializing, conda won't be added to your PATH, and you'll have to manually add it later. - Using the wrong installer – Make sure you download the Linux installer for x86_64 if you're on a standard Intel/AMD machine. Downloading the macOS or Windows version will fail.
- Forgetting to source ~/.bashrc – If you don't reopen the terminal or source the file, the
condacommand won't be found. - Running
sudo conda– Avoid usingsudowith conda commands; it can lead to permission issues and break the installation.
Tips
- Use environments – Create separate conda environments for different projects to avoid dependency conflicts. For example:
conda create -n myproject python=3.9. - Keep Anaconda updated – Regularly run
conda update --allto get the latest package versions and security patches. - Set the channel priority – If you plan to install packages from conda-forge, consider setting the channel priority to strict:
conda config --set channel_priority strict. - Use Miniconda for lighter setups – If you don't need the hundreds of pre-installed packages, consider Miniconda, which is a minimal bootstrap version of Anaconda.
- Add conda to your path manually (if needed) – If you skipped conda init, you can add the following line to your
~/.bashrc:
Then source the file.export PATH="$HOME/anaconda3/bin:$PATH"
Troubleshooting
conda: command not found
This usually means conda isn't in your PATH. Re-runsource ~/.bashrcor restart your terminal. If it still fails, check that the installation directory exists and that the PATH line is correct in your~/.bashrc.- Permission denied when running the installer
Ensure the script has execute permissions:chmod +x Anaconda3-*.sh, then run withbashagain. - Checksum mismatch
If the SHA-256 doesn't match, the download may be corrupted. Delete the file and re-download it. - Disk space issues
Anaconda needs ~3 GB. Check free space withdf -h. If you're low, clean up temporary files or install Miniconda instead. - Python version conflicts
If your system'spythoncommand still points to the system Python, check the order of your PATH. The Anaconda bin directory should be first. Usewhich pythonto see which one is being used. - SSL errors during package installs
If you encounter SSL certificate errors, try updating theca-certificatespackage:conda update ca-certificates.
Frequently Asked Questions
Can I install Anaconda without sudo?
Yes, Anaconda installs entirely in your home directory by default, so no root privileges are needed. This is one of its advantages.
How do I uninstall Anaconda?
Simply remove the installation directory (e.g., rm -rf ~/anaconda3) and delete the lines added to your ~/.bashrc by conda init. Also remove the backup file ~/.bashrc-anaconda3.bak if it exists.
What's the difference between Anaconda and Miniconda?
Anaconda comes with over 250 pre-installed packages, while Miniconda is a minimal installer that only includes conda, Python, and a few dependencies. You can install additional packages as needed.
Can I use Anaconda with Python 2?
Anaconda historically offered Python 2 versions, but as of 2020, Python 2 is deprecated and no longer supported. Current Anaconda versions use Python 3.x.
How do I create a new conda environment?
Use the command: conda create -n env_name python=3.9, replacing env_name and the Python version as desired. Then activate it with conda activate env_name.
Why is conda so slow to solve environments?
This is a known issue with conda's dependency solver. To speed it up, try using the mamba package manager, which is a faster drop-in replacement. Install it with conda install mamba and then use mamba commands instead.