How to Install Anaconda on Ubuntu: A Step-by-Step Tutorial

How to Install Anaconda on Ubuntu: A Step-by-Step Tutorial

Anaconda is a popular Python/R data science platform available for novice users, data scientists, and other scientific communities. The platform is an open-source distribution (distro), meaning users can experiment with Python/R for data science and machine learning on commonly used operating systems like Linux, Windows, and Mac OS X.

In this tutorial, we will provide a step-by-step guide on how to install the latest version of Anaconda on a virtual private server (VPS) running Ubuntu 18.04, 20.04, and 22.04. We will also cover the process of testing the Anaconda connection and updating the distribution altogether.

What Is Conda, Anaconda, and Miniconda?

As an open-source distribution for Python/R, Anaconda can be divided into three main versions – Anaconda and Miniconda are free, and Anaconda Business is a paid version for enterprises. This tutorial will compare only the free versions, as they have everything a beginner data scientist would need.

MinicondaAnaconda
DifficultyFor advanced usersFor beginners
ResourcesInstallation is quick, and lightweightInstallation is lengthy and takes a lot of space
PackagesPackages need to be installed manuallyOver one thousand packages will be preinstalled

As seen from the table, the full Anaconda version is more suited for beginners because all the required packages are already included. However, keep in mind that having a lot of packages available doesn’t mean you will use them all, not to mention the increased installation time and size. More advanced users go with Miniconda and install only the necessary packages via the Conda package manager.

Conda helps users find and install over 1,500 open-source packages individually from its repository. Conda is extra helpful if you need a different Python version and don’t want to switch between different Anaconda environments. In other words, Conda does all the switching for you.

Installing Anaconda on Ubuntu in 3 Steps

The easiest way to install Anaconda on Ubuntu 18.04, 20.04, and 22.04 is to use the latest Anaconda installation script. In our case, the current version of Anaconda is 2022.05 as of May 10, 2022. The developers might have released a new version by the time you’re reading this, but the installation process should remain the same.

Important! We are installing the non-GUI version of Anaconda because virtual private servers do not support a graphical user interface.

Start by logging to your VPS via SSH as the root user.

Step 1 – Download and Install Anaconda Script

Once you’re logged into your VPS, refresh the APT command to synchronize all repositories via the command line:

sudo apt-get update

Move to the /tmp directory:

cd /tmp

Download the newest Anaconda installer with the wget command. If you don’t have it, install it first:

apt-get install wget

Download the Anaconda installer:

wget https://repo.anaconda.com/archive/Anaconda3-2022.05-Linux-x86_64.sh

Once the download is complete, verify the hash code integrity of the package:

sha256sum Anaconda3-2022.05-Linux-x86_64.sh

The output will notify if any errors occurred. If there are no errors, move on to the actual installation step. To continue, run the Anaconda bash shell script:

bash Anaconda3-2022.05-Linux-x86_64.sh

If you want to install Miniconda instead, use the following commands consecutively:

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

After running the bash command, you’ll be welcomed to the Anaconda setup. However, you must review and agree to its license agreement before the installation. Hit Enter to continue.

Command line window for using the bash script for installing Anaconda

Pressing the space bar a few times will bring you to the end of the license agreement, where you can accept the terms. Type in “yes” as highlighted and hit Enter.

Anaconda installer window showcasing license agreements that need to be accepted to proceed with the Anaconda installation

Step 2 – Choose Installation Directory

After agreeing to the license terms, the following prompt will ask you to input the directory where to install the Anaconda on the Ubuntu system. The default location is the user’s HOME directory on Ubuntu.

It is recommended to have Anaconda installed in this location. Therefore, press Enter to confirm the default location.

Command line window displaying Anaconda installation location option

Pro Tip

By entering the desired directory manually, you can change the install location to the path you want.

In the next prompt, you will see that the installation process has started. Wait a few minutes until the installer successfully completes the installation process. Type “yes” once more and press Enter.

Last step of Anaconda installation shown on the command line

Congratulations, you have successfully installed Anaconda!

Step 3 – Test the Connection

With the installation done, the next step is to activate the added environment settings using the following command:

source ~/.bashrc

Then, test out the connection:

conda info

If the installation process was successful, a piece of similar-looking information should be displayed:

Conda command output showcasing full information about recently installed Anaconda package

Updating Anaconda

In case you ever need to update Anaconda, start by updating the conda package manager first:

conda update conda

Then, update the actual Anaconda distribution:

conda update anaconda

Wait a few minutes until the installer successfully completes the Anaconda installation process, type “y” and press Enter.

Uninstalling Anaconda

In order to uninstall Anaconda, install the following anaconda-clean package:

conda install anaconda-clean

Lastly, remove all Anaconda-related files and directories:

anaconda-clean

Conclusion

Anaconda is a powerful scientific computing distribution used by some of the most prominent organizations in the world. Despite the problematic nature of data sciences, Anaconda makes learning easy with the help of thousands of open-source packages and libraries.

In this tutorial, we’ve compared the different Anaconda versions and covered the installation process for Anaconda and Miniconda on Ubuntu 18.04, 20.04, and 22.04.

We hope this article helped you to install Anaconda on your Ubuntu machine. If you have any questions or suggestions, be sure to leave them in the comments below.

Author
The author

Ignas R.

Ignas is a Technical Content Writer at Hostinger. After helping people tackle even the most complex technical issues as a Customer Success Specialist, his current goal is to write easy-to-follow articles so that these issues will not happen at all. During his free time, Ignas likes to play video games and fix up things around his house.