How to Install Anaconda on CentOS 8

Published on

4 min read

How to Install Anaconda on CentOS 8

Anaconda is the most popular Python/R data science and machine learning platform. It is used for large-scale data processing, predictive analytics, and scientific computing.

Anaconda distribution ships with more than 1,500 open-source data packages. It also includes the conda command-line tool and a desktop graphical user interface called Anaconda Navigator.

In this tutorial, we will explain how to install Anaconda Python Distribution on CentOS 8.

Installing Anaconda

At the time of writing this article, the latest stable version of Anaconda is version 2019.10. Before downloading the Anaconda installer script, visit the Anaconda Downloads page and check if there is a new version of Anaconda for Python 3 available for download.

CentOS Download Anaconda

Complete the following steps to install Anaconda on CentOS 8:

  1. Download the Anaconda installation script using the link that you copied from the Downloads page:

    wget -P /tmp https://repo.anaconda.com/archive/Anaconda3-2019.10-Linux-x86_64.sh

    The download may take some time depending on your connection speed.

    If you are installing Anaconda on a Desktop machine, you can download the script using your web browser .

  2. Verify the data integrity of the script with the sha256sum command:

    sha256sum Anaconda3-5.3.1-Linux-x86_64.sh

    The output should look like the following:

    46d762284d252e51cd58a8ca6c8adc9da2eadc82c342927b2f66ed011d1d8b53  /tmp/Anaconda3-2019.10-Linux-x86_64.sh

    Make sure the hash printed from the command above matches the one available at the Anaconda with Python 3 on 64-bit Linux page for your appropriate Anaconda version.

    CentOS Anaconda Installer Hash
  3. Start the Anaconda installation process by executing the installation script:

    bash Anaconda3-2019.10-Linux-x86_64.sh

    You should see an output like the following:

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

    Press ENTER to continue, and then press ENTER to scroll through the license. You’ll be asked to approve the license terms:

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

    Type yes to accept the license and the installer will ask you to choose the installation location:

    Anaconda3 will now be installed into this location:
    /home/linuxize/anaconda3
    
    - Press ENTER to confirm the location
    - Press CTRL-C to abort the installation
    - Or specify a different location below

    The default location is fine for most users. Press ENTER to confirm the location and installation process will continue.

    If you get an error saying bunzip2: command not found, install the bzip2 package with: sudo dnf install bzip2, and re-run the installation script

    The installation may take some time to complete. Once done, you’ll see the following output:

    Preparing transaction: done
    Executing transaction: done
    installation finished.
    Do you wish the installer to initialize Anaconda3
    by running conda init? [yes|no]
    

    Type yes, press ENTER and the script will add conda to your PATH :

    ==> For changes to take effect, close and re-open your current shell. <==
    
    If you'd prefer that conda's base environment not be activated on startup, 
    set the auto_activate_base parameter to false: 
    
    conda config --set auto_activate_base false
    
    Thank you for installing Anaconda3!
    
    ...
    

    To activate the Anaconda installation, you can either close and re-open your shell or load the new PATH environment variable into the current shell session by typing:

    source ~/.bashrc
  4. Use the conda command to verify the Anaconda installation. The following command will display information about the installation:

    conda info
        active environment : base
        active env location : /home/vagrant/anaconda3
                shell level : 1
        user config file : /home/vagrant/.condarc
    populated config files : 
            conda version : 4.7.12
        conda-build version : 3.18.9
            python version : 3.7.4.final.0
        ...

Updating Anaconda

Updating the Anaconda is a pretty straight forward process, first update the conda tool with:

conda update conda

When prompted to confirm the update, type y to proceed.

Once conda is updated, proceed with the Anaconda update:

conda update anaconda

Same as with the previous command, when prompted, type y to proceed.

Do not forget to regularly update your Anaconda installation.

Uninstalling Anaconda

To uninstall Anaconda from your CentOS system, first remove the Anaconda installation directory:

rm -rf ~/anaconda3

Edit the ~/.bashrc file and remove the Anaconda directory from the PATH environment variable:

~/.bashrc
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/home/linuxize/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/home/linuxize/anaconda3/etc/profile.d/conda.sh" ]; then
        . "/home/linuxize/anaconda3/etc/profile.d/conda.sh"
    else
        export PATH="/home/linuxize/anaconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda initialize <<<

Run the following rm command to remove the hidden files and folders from the user home directory:

rm -rf ~/.condarc ~/.conda ~/.continuum

Conclusion

Now that you have downloaded and installed Anaconda your CentOS system, you can check the official Getting started with conda guide.

If you hit a problem or have feedback, leave a comment below.