How to Install Anaconda on Ubuntu 20.04

Anaconda, an open-source platform for Python and R programming, is an environment manager available in Linux. It has a large collection of various open-source packages. It can be used for data science projects. You can easily install Anaconda on Ubuntu systems. 

Anaconda platform provides the capability to process huge datasets. It also provides the capability to perform predictive analysis. It can easily install and run on various operating systems. Also, it makes it easier to install various packages and repositories. You can use those packages for Python And R programming. Hence, it is an excellent choice for all Python developers. 

In this tutorial, I will guide you on how to install and run Anaconda on your Ubuntu 20.04 systems. 

Prerequisites

For this tutorial, you will need a 64-bit CPU with a minimum of 20 GB of space. Plus, you will also need internet access and sudo privilege to install the required packages.

Install Anaconda on Ubuntu

1. Install Dependencies

The most important step before installing any software or package is to update the package’s repository. You can use the following command to update the packages:

sudo apt update 

Alternatively, you can also use the apt-get command.

sudo apt-get update

Anaconda also comes with a graphical user interface (GUI) that allows you to manage its packages. If you wish to install GUI as well, then perform the next step. Otherwise, you can move forward to step 2.

In this step, we will install the curl package using the install command.

sudo apt install curl -y
Install Anaconda on Ubuntu

Next, we will install the dependency packages for Anaconda Navigator. For this step, you require certain libraries that you can install as shown below: 

sudo apt install libgl1-mesa-glx libegl1-mesa libxrandr2 libxrandr2 libxss1 libxcursor1 libxcomposite1 libasound2 libxi6 libxtst6
Install Anaconda on Ubuntu

Finally, you have updated and installed the required packages.

2. Download Anaconda on Ubuntu

Now that the packages are updated, we will proceed with the download of the Anaconda script. We will download from its official site. To download, execute the following command: 

$ wget -P /tmp https://repo.anaconda.com/archive/Anaconda3-2021.05-Linux-x86_64.sh
install Anaconda on Ubuntu 1

This command fetches the Anaconda script files for Linux. Notice here that we have provided the latest version of Anaconda. At the time of your installation, make sure to replace it with the current version. 

On the other hand, you can also use curl command to download the Anaconda installer from its official site. Make sure to check for the latest version and use that version in the command. After that, execute the curl command.

curl --output anaconda.sh https://repo.anaconda.com/archive/Anaconda3-2021.05-Linux-x86_64.sh 

3. Verify the Downloaded Script

To verify the integrity of the downloaded script, we will use the SHA-256 checksum. SHA-256 hashes compare both integrity and authenticity of the data. It also makes sure that the file is error-free. To perform this step, execute the sha256sum command. You will write sha256sum followed by the name of the Anaconda package. 

$ sha256sum /tmp/Anaconda3-2021.05-Linux-x86_64.sh

You will get an alphanumeric string as checksum outout.

Next, head over to the Anaconda verification page on its website. Locate the version. After that, click the same architecture entry as the one you downloaded. You will see that the output you got on the terminal will match the SHA256 value. 

Install Anaconda on Ubuntu

Finally, you have verified your downloaded package.

4. Install Anaconda on Ubuntu

Now, we will begin with the installation of the Anaconda manager. Use the bash command followed by the package name. We are using the bash command because the downloaded script was a bash script. 

$ bash /tmp/Anaconda3-2020.02-Linux-x86_64.sh

You will see a license on the terminal after the command is executed. Press the “Enter” key to continue with the installation. After that, type “Yes” to accept the license. Next, the installer will ask for the location. To simplify the installation process, click the default location and press the “Enter” key. 

Next, you will be required to select the installation location. For simplicity, go with the default location. Next, press “Enter” to continue. 

After the installation has completed, you will set the PATH variable for Anaconda. The PATH variable allows you to run Anaconda from any directory you want to on your computer. Type “Yes” to proceed with this step. 

After that, close your terminal to complete the installation. Next, load the new PATH variable into the environment using the source command as shown below: 

$ source ~/ .bashrc

Finally, you have successfully installed Anaconda. 

It is now time to verify the installation. For this step, run the conda list command in the Anaconda environment. 

conda list 

You will see the list of all the packages that are available for installation via the Anaconda manager. Alternatively, you can also run the conda command to verify the installation. 

Conda
Install Anaconda on Ubuntu

5. Open Anaconda GUI

Now that the Anaconda package manager is installed, you can open its GUI. Execute the following command in the Anaconda environment: 

$ anaconda-navigator
Install Anaconda on Ubuntu

Now, you can explore the packages, and install Python. To know more about using Python on different distribution, you can check our Python article.

6. Update Anaconda

Although you have installed Anaconda successfully, there might still be updates and packages available. It is crucial to keep them up-to-date. Always ensure that you are working with updated packages. To update Anaconda, type: 

conda update conda

Type “Yes” to continue with the update. You can update the Anaconda distribution once the conda is updated by using the following command:

conda update anaconda

You will get the same prompt, type “Yes” to proceed. 

Alternatively, you can also use the update command with –all flag to update the complete distribution.

conda update --all

This command will update all the available packages. 

Remove Anaconda from Ubuntu

For instance, you no longer want to use Anaconda, and you wish to uninstall it. There are multiple ways to achieve that. Firstly, you will remove the installation folder. You will also remove its environment variables using the rm command. 

rm -rf /usr/local/anaconda

Secondly, edit the ~/.bashrc file, and search for the Anaconda directory. 

nano ~/.bashrc

After locating it, remove it from the file. Usually, you will find this directory with PATH variable in the bashrc file. 

# added by Miniconda3 installer
export PATH="/root/miniconda3/bin:$PATH"

Save the file, and hit the “Enter” key. Then exit from the bash editor.

Alternatively, you can use the anaconda-clean module to uninstall Anaconda. With this command, you will be able to remove configuration files of Anaconda.

conda install anaconda-clean

After that, run this module and hit “Y” when prompted to remove the package. If you do not want the prompts to appear repeatedly, just type --yes after the command. Furthermore, this command will also create a backup of your Anaconda information in the .anaconda_backup directory. 

anaconda-clean

After that, you will remove the Anaconda directory using the rm command

rm -rf ~/anaconda3

Finally, you have removed Anaconda from Ubuntu 20.04.

The article has guided you on how to install Anaconda on Ubuntu systems. It has also discussed how to open Anaconda GUI. Make sure to update your packages frequently and select the most recent version of the Anaconda package. In case of questions, feel free to comment below.

If this guide helped you, please share it.

Leave a Reply
Related Posts