How to Install Anaconda on Ubuntu
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. 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.
Miniconda | Anaconda | |
Difficulty | For advanced users | For beginners |
Resources | Installation is quick, and lightweight | Installation is lengthy and takes a lot of space |
Packages | Packages need to be installed manually | Over 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.
Sugested Reading
Want to learn how to manage your packages in Python? Check out our guide to learn how to install Pip on Ubuntu.
How to Install Anaconda on Ubuntu in 3 Steps
The easiest way to install Anaconda on Ubuntu is to use the latest Anaconda installation script.
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.
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.
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.
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.
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.
Congratulations, you have successfully installed Anaconda!
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:
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.
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.
Sugested Reading
Discover our guide to learn how to list installed packages on Ubuntu.
Comments
June 02 2019
thank you very much for the information, it served me a lot and I managed to install.
March 07 2023
for me does not work until I add it to the path using export PATH=/home/elahe/anaconda3/bin:$PATH
March 10 2023
Hey there! Thank you for your insights. You have probably installed Anaconda to other directory than the default one (user’s HOME directory). That's why you need to specify the path before using Anaconda.
October 20 2023
Great job. Thank you for this tutorial which appear very clear to understand for me and hope for else. I work in ubuntu 22.04. and just a copy and past helped to have it done.
October 31 2023
You're welcome! Glad to hear that ?