Anaconda is an open-source distribution and package manager for Python and R. Anaconda is a cross-platform application that can be installed on all operating systems including Ubuntu Linux. Anaconda is used to manage data science, artificial intelligence, and machine learning projects. Moreover, it is also used to create and manage environments. 

Anaconda comes pre-installed with more than 250 packages and the capability to install additional packages and libraries including, Numpy, pandas, Pythorh, etc. Anaconda libraries and packages help data scientists visualize, analyze, and compute data for scientific computing.

How to Install Anaconda on Ubuntu 24.04

Ubuntu does not include the Anaconda package in its official repository. That is why we need to download the Anaconda package through the wget command from its official website and then install it using the bash command. Check the following steps to install Anaconda on Ubuntu 24.04.

Step 1: Update System Repositories

Press CTRL + Alt + T to open the Terminal and then ensure that system packages are updated or upgraded to their latest version by running this command:

sudo apt update && sudo apt upgrade

Step 2: Download Anaconda

Before downloading the Anaconda on Ubuntu, change the current working directory to the /tmp directory. The /tmp directory stores the files temporarily and deletes them when you close the session. To change the current working directory to the /tmp directory, run this command:

cd /tmp

Download the Anaconda installer file once you have moved your current working directory to the /tmp directory. To download the Anaconda installer, visit the official Anaconda website, locate the desired Linux x64 version, copy its link, and provide it to the wget command to download the Anaconda setup on Ubuntu:

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

Note: Downloading Anaconda will take time, so be patient.

Note: If you do not have the wget utility command installed, then run this command to install it on Ubuntu:

sudo apt install wget

Step 3: Check Anaconda Package Integrity

Once the Anaconda setup file is downloaded, use the checksum utility to make sure it is not corrupted and safe to install on Ubuntu:

sha256sum Anaconda3-2024.02-1-Linux-x86_64.sh

Step 4: Install Anaconda

Once you are sure that the Anaconda file is safe to install, then, run the given script to install Anaconda on Ubuntu:

bash Anaconda3-2024.02-1-Linux-x86_64.sh

After executing this command, press the Enter button to proceed with the installation, as shown below:

You will be presented with the End User License Agreement. To read it, keep pressing the Enter button:

Once you read it completely, type yes and press the Enter button to accept the Anaconda license terms:

Now, press the Enter button to install the Anaconda in the specified location which is the Home directory by default, or you can also specify a different location:

Once the installation is finished, type yes and press Enter to start the Anaconda on startup, or type no to start and activate it by yourself manually later:

Lastly, close and restart the Terminal, so that the Anaconda environment changes can take effect:

Step 5: Activate Anaconda Environment

After installing Anaconda, it is a must to activate the Anaconda working environment to use it. To activate the Anaconda environment, run this command:

source ~/.bashrc

This command will reload the .bashrc file so that changes can stored in that file which will result in activating the Anaconda environment:

Step 6: Verify Installation

Once you installed the Anaconda on Ubuntu, verify its installation by checking its complete information by running this command in Terminal:

conda info

Alternatively, you can also verify the Anaconda installation on Ubuntu, by checking its version, through the given command:

conda --version

How to Update Anaconda on Ubuntu 24.04

If you have already installed Anaconda on Ubuntu, and want to upgrade it to the latest version. Then, you first need to update the Anaconda package manager by running this command:

conda update conda

Once the package manager is updated, then, update the Anaconda by running this command:

conda update anaconda

How to Fix the “PackageNotInstalledError: Package is not installed in prefix” Error?

While updating Anaconda on Ubuntu using the conda update anaconda command, I got the “PackageNotInstalledError: Package is not installed in prefix” error in the Terminal, as shown below:

conda update anaconda

To fix the “PackageNotInstalledError: Package is not installed in prefix” error, simply execute the conda install anaconda command, as shown below:

conda install anaconda

Note: When the prompt asks for the confirmation, simply type y and hit the Enter button:

Once the above command gets executed, you can then update the Anaconda by running the conda update anaconda command.

How to Use Anaconda on Ubuntu 24.04

As of now, Anaconda is installed on Ubuntu 24.04. Now, let’s learn to manage and the usage of Anaconda on Ubuntu. Check the following steps to learn the usage of Anaconda on Ubuntu 24.04.

Usage 1: List Installed Anaconda Packages

You can retrieve the list of installed packages on Ubuntu, by running this command:

conda list

Usage 2: Install Python Package Using Anaconda

You can install any Python package on Ubuntu, by specifying the package name to the conda install command, as shown below:

conda install pandas

Usage 3: Create an Environment Using Anaconda

To create an environment on Ubuntu, use the conda create command and specify the environment name using the –name flag, as shown below:

conda create --name env_1

Usage 4: Activate an Environment using Anaconda

You can activate the environment in Anaconda by specifying the environment name to the conda activate command as shown below:

conda activate env_1

Usage 5: Deactivate an Environment using Anaconda

To deactivate the environment, simply run the given command:

conda deactivate

How to Uninstall Anaconda from Ubuntu 24.04

You can not directly remove Anaconda from Ubuntu 24.04. However, to remove the Anaconda from Ubuntu, first, you need to install the anaconda-clean package. Run this command to install the anaconda-clean package:

conda install anaconda-clean

Now, run the anaconda-clean package to remove anaconda from Ubuntu, as shown below:

anaconda-clean

Type y and hit the Enter button to remove Anaconda from Ubuntu:

To completely remove Anaconda from Ubuntu along with its directory, run this command:

rm -rf ~/anaconda3

Conclusion

To install Anaconda on Ubuntu, visit the official Anaconda website, locate the x64 Linux Anaconda package, copy its URL, and provide to the wget command, just like that “wget https://repo.anaconda.com/archive/Anaconda3-2024.02-1-Linux-x86_64.sh” to download Anaconda in the Terminal. After that, run the “bash Anaconda3-2024.02-1-Linux-x86_64.sh” script to install Anaconda on Ubuntu. Once installed, you can verify its installation by running the “conda –version” command. To uninstall Anaconda from Ubuntu, run the rm -rf ~/anaconda3 command.