Anaconda is an open-source package manager and a distribution of the Python and R programming languages. It is commonly used for data science, machine learning, big data processing, scientific computing, and predictive analytics. It can be installed on all major operating systems including Windows, Linux, and macOS. Anaconda helps developers to install and manage Python dependencies in a single installation. It offers a collection of over 7,500+ open-source packages.
In this post, we will show you how to install Anaconda Python Distribution on Rocky Linux 8.
Step 1 – Download Anaconda Installer Script
First, you will need to download the latest version of the Anaconda installation script from its official website.
You can download it using the following command:
wget https://repo.anaconda.com/archive/Anaconda3-2021.05-Linux-x86_64.sh
Once the download is completed, create the sha256 cryptographic hash of the installer file using the command below:
sha256sum Anaconda3-2021.05-Linux-x86_64.sh
You will get the following output:
2751ab3d678ff0277ae80f9e8a74f218cfc70fe9a9cdc7bb1c137d7e47e33d53 Anaconda3-2021.05-Linux-x86_64.sh
Now, match the result to the hashes available on the Anaconda website.
If the result matches, you can proceed to the next step.
Step 2 – Install Anaconda on Rocky Linux 8
Now, run the Anaconda installer script to install the Anaconda to your system.
bash Anaconda3-2021.05-Linux-x86_64.sh
You will be asked to accept the license terms, as shown below:
Welcome to Anaconda3 2021.05 In order to continue the installation process, please review the license agreement. Please, press ENTER to continue >>> Do you accept the license terms? [yes|no] [no] >>> yes
Type yes and hit Enter. You will be asked to set the installation location:
Anaconda3 will now be installed into this location: /root/anaconda3 - Press ENTER to confirm the location - Press CTRL-C to abort the installation - Or specify a different location below [/root/anaconda3] >>>
Press Enter to proceed with the default location. You will be asked to init Anaconda:
PREFIX=/root/anaconda3 installation finished. Do you wish the installer to initialize Anaconda3 by running conda init? [yes|no] [no] >>> yes
Type yes and hit Enter to init Anaconda and finish the installation:
==> 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! =========================================================================== Working with Python and Jupyter notebooks is a breeze with PyCharm Pro, designed to be used with Anaconda. Download now and have the best data tools at your fingertips. PyCharm Pro for Anaconda is available at: https://www.anaconda.com/pycharm
Now, activate the Anaconda installation using the following command:
source ~/.bashrc
You will get the Anaconda shell in the following output:
(base) [root@RockyLinux8 ~]#
Step 3 – Verify Anaconda Installation
Now, run the following command to test the Anaconda installation.
conda info
You will get the following output:
active environment : base active env location : /root/anaconda3 shell level : 1 user config file : /root/.condarc populated config files : conda version : 4.10.1 conda-build version : 3.21.4 python version : 3.8.8.final.0 virtual packages : __linux=4.18.0=0 __glibc=2.28=0 __unix=0=0 __archspec=1=x86_64 base environment : /root/anaconda3 (writable) conda av data dir : /root/anaconda3/etc/conda conda av metadata url : https://repo.anaconda.com/pkgs/main channel URLs : https://repo.anaconda.com/pkgs/main/linux-64 https://repo.anaconda.com/pkgs/main/noarch https://repo.anaconda.com/pkgs/r/linux-64 https://repo.anaconda.com/pkgs/r/noarch package cache : /root/anaconda3/pkgs /root/.conda/pkgs envs directories : /root/anaconda3/envs /root/.conda/envs platform : linux-64 user-agent : conda/4.10.1 requests/2.25.1 CPython/3.8.8 Linux/4.18.0-305.7.1.el8_4.x86_64 rocky/8.4 glibc/2.28 UID:GID : 0:0 netrc file : None offline mode : False
To list all packages available with Anaconda, run the following command:
conda list
You should see all packages in the following output:
# packages in environment at /root/anaconda3: # # Name Version Build Channel _ipyw_jlab_nb_ext_conf 0.1.0 py38_0 _libgcc_mutex 0.1 main alabaster 0.7.12 pyhd3eb1b0_0 anaconda 2021.05 py38_0 anaconda-client 1.7.2 py38_0 anaconda-navigator 2.0.3 py38_0 anaconda-project 0.9.1 pyhd3eb1b0_1 anyio 2.2.0 py38h06a4308_1 appdirs 1.4.4 py_0 argh 0.26.2 py38_0 argon2-cffi 20.1.0 py38h27cfd23_1 asn1crypto 1.4.0 py_0 astroid 2.5 py38h06a4308_1 astropy 4.2.1 py38h27cfd23_1 async_generator 1.10 pyhd3eb1b0_0 atomicwrites 1.4.0 py_0 attrs 20.3.0 pyhd3eb1b0_0
Step 4 – Update Anaconda
Anaconda provides a conda utility to update the Anaconda package. First, run the following command to update the conda utility to the latest version.
conda update conda
You will get the following output:
## Package Plan ## environment location: /root/anaconda3 added / updated specs: - conda The following packages will be downloaded: package | build ---------------------------|----------------- conda-4.10.3 | py38h06a4308_0 2.9 MB xmltodict-0.12.0 | pyhd3eb1b0_0 13 KB ------------------------------------------------------------ Total: 2.9 MB The following packages will be UPDATED: conda 4.10.1-py38h06a4308_1 --> 4.10.3-py38h06a4308_0 The following packages will be DOWNGRADED: xmltodict 0.12.0-py_0 --> 0.12.0-pyhd3eb1b0_0 Proceed ([y]/n)? y Downloading and Extracting Packages xmltodict-0.12.0 | 13 KB | #################################################################################################### | 100% conda-4.10.3 | 2.9 MB | #################################################################################################### | 100% Preparing transaction: done Verifying transaction: done Executing transaction: done
Next, update the Anaconda with the following command:
conda update anaconda
Step 5 – Create an Environment Using Anaconda
Anaconda allows you to create an environment to organize projects based on Python versions.
To create a new environment named conda_env, run:
conda create --name conda_env python=3
You will get the following output:
# # To activate this environment, use # # $ conda activate conda_env # # To deactivate an active environment, use # # $ conda deactivate
Now, activate the environment using the following command:
conda activate conda_env
You will get the following shell:
(conda_env) [root@RockyLinux8 ~]#
Next, verify the Python version using the following command:
python --version
You will get the following output:
Python 3.10.0
To list all your environments, run the following command:
conda info --envs
You should see the following output:
(conda_env) [root@RockyLinux8 ~]# conda info --envs # conda environments: # base /root/anaconda3 conda_env * /root/anaconda3/envs/conda_env
To deactivate from the Anaconda environment, run the following command:
conda deactivate
To remove the conda_env, run the following command:
conda env remove -n conda_env
Sample output:
Remove all packages in environment /root/anaconda3/envs/conda_env:
Step 6 – Uninstall Anaconda
If you want to uninstall Anaconda from your system, you will need to install the anaconda-clean utility to your system. You can install it using the following command:
conda install anaconda-clean
Once installed, you will get the following output:
The following packages will be downloaded: package | build ---------------------------|----------------- anaconda-clean-1.1.0 | py38h06a4308_1 244 KB ------------------------------------------------------------ Total: 244 KB The following NEW packages will be INSTALLED: anaconda-clean pkgs/main/linux-64::anaconda-clean-1.1.0-py38h06a4308_1 Proceed ([y]/n)? y
Next, run the following command to uninstall Anaconda from your system.
anaconda-clean
You will get the following output:
Delete .conda? (y/n): y Backup directory: /root/.anaconda_backup/2021-10-22T073105
Next, remove all files and directories created by Anaconda using the following command:
rm -rf ~/.condarc ~/.conda ~/.continuum
Next, edit the .bashrc file and remove all lines added by Anaconda:
nano ~/.bashrc
Remove the following lines:
# >>> conda initialize >>> # !! Contents within this block are managed by 'conda init' !! __conda_setup="$('/root/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)" if [ $? -eq 0 ]; then eval "$__conda_setup" else if [ -f "/root/anaconda3/etc/profile.d/conda.sh" ]; then . "/root/anaconda3/etc/profile.d/conda.sh" else export PATH="/root/anaconda3/bin:$PATH" fi fi unset __conda_setup # <<< conda initialize <<<
Save and close the file when you are finished.
Conclusion
In the above guide, we explained how to install Anaconda on Rocky Linux 8. We also explained how to update the Anaconda and create an environment using Anaconda. For more information, visit the Anaconda documentation page. Try it today on your virtual private server from Atlantic.Net!