How to Install Anaconda on Ubuntu 24.04

Anaconda is a well-liked Python and R language distribution used for machine learning, data analysis, and scientific computing. It comes with a wide range of essential pre-installed packages and users can install additional packages as required. Anaconda also enables us to create a virtual environment to isolate projects and dependencies and manage different package versions. Additionally, anaconda supports IDEs like pycharm, spyder, and VS code for project development and deployment.

How to Install Anaconda on Ubuntu 24.04?

To install Anaconda on Ubuntu 24.04, follow the below procedure:

Step 1: Download Anaconda’s Installer

To download the latest version of Anaconda on Ubuntu, navigate to its official website from the Firefox browser.  Under the “Linux” category, download the Anaconda’s installer script:

Install Anaconda on Ubuntu 24.04

Alternatively, you can install the installer script using the “wget” command:

wget https://repo.anaconda.com/archive/Anaconda3-2024.02-1-Linux-x86_64.sh
Install Anaconda on Ubuntu 24.04 a

The installer will be downloaded in the Ubuntu’s “Downloads” directory. For confirmation, navigate to the “Downloads” through the “cd” and view the files using the “ls” command:

cd Downloads/ls
Install Anaconda on Ubuntu 24.04 b

Step 2: Execute the Installer Script

Install the Anaconda on Ubuntu by executing the installer script through the “sh <path to Anaconda Installer>” command:

sh ./Downloads/Anaconda3-2024.02-1-Linux-x86_64.sh

This operation will ask you to continue the installation process, hit “Enter” to proceed: 

Install Anaconda on Ubuntu 24.04 c

After viewing the “END USER LICENSE AGREEMENT”, you need to accept these terms to continue the installation. Type “yes” and press “Enter” to proceed:

Install Anaconda on Ubuntu 24.04 d

In the next prompt, you will be asked to specify or confirm the Anaconda installation location. To install Anaconda on the default selected location “/home/<user>/anaconda3”, hit “Enter”. You can also type the specific location for Anaconda installation as per your preferences:

Install Anaconda on Ubuntu 24.04 e

The next prompt will ask you to activate the Anaconda’s “base” environment, press “yes” to activate. This will complete the installation procedure:

Install Anaconda on Ubuntu 24.04 f

Step 3: Test Anaconda

To test whether the Anaconda is installed on the system or not, list down the Anaconda’s pre-installed packages using the “conda list” command:

conda list
Install Anaconda on Ubuntu 24.04 g

That is all about the Anaconda installation on Ubuntu 24.04. To get started with Anaconda, go through the below section.

How to Use Anaconda on Ubuntu 24.04?

The Anaconda is used for project development in isolated environments. It is also utilized for scientific computation and data analysis. To get started with Anaconda’s basic use, let’s configure the simple virtual environment and execute the Python script. For demonstration, go through the following steps:

Step 1: Create a New Virtual Environment 

Create a new virtual environment in Anaconda to use with Python3, utilize the “conda create –name <virtual env-name> python=3” command:

conda create --name venv python=3

In the above command, we have created the “venv” environment to use with Python3. However, users can configure virtual environments with any Python and R version according to requirements:

Install Anaconda on Ubuntu 24.04 h

To download the essential packages in a newly created virtual environment, hit “Y”:

Install Anaconda on Ubuntu 24.04 i

Step 2: Activate the Environment

Now, activate the Anaconda’s environment using the “conda activate <virtual env-name>” command:

conda activate venv
Install Anaconda on Ubuntu 24.04 j

Step 3: Create Python Script

Create a simple Python script in the nano editor through the below command:

sudo nano demo.py
Install Anaconda on Ubuntu 24.04 k

Paste the below simple Python program into the file. This will print the quoted string on the console:

print("Hello! Welcome to Its Linux FOSS Tutorial")

Press “CTRL+S” to save the file and “CTRL+X” to exit the editor.

Step 4: Execute Script

Now, execute the Python script in the “venv” isolated environment using the “python3 <file-name.py>” command:

python3 demo.py
Install Anaconda on Ubuntu 24.04 l

Additionally, if users need to import some package or library in a project, they can install the package in an activated environment. In the below command, we have installed the “pandas” library using the “pip3” Python package manager:

pip3 install pandas
Install Anaconda on Ubuntu 24.04 m

Step 5: Deactivate Virtual Environment

To deactivate the virtual environment, simply execute the “conda deactivate” command:

conda deactivate
Install Anaconda on Ubuntu 24.04 n

How to Update Anaconda in Ubuntu 24.04?

To update Anaconda in Ubuntu 24.04, first, update the “conda” package manager. Then, update the Anaconda’s meta package “anaconda”.

Update Conda Package Manager

To update “conda” Anaconda’s package manager, utilize the below command:

conda update conda
Install Anaconda on Ubuntu 24.04 o

Update Anaconda Package

After updating the package manager, now update the “anaconda” package:

conda update anaconda
Install Anaconda on Ubuntu 24.04 p

Note: At that point, a beginner may face the error “PackageNotInstalledError” while updating “anaconda”. This stated error occurs if the “anaconda” meta package is missing. With Anaconda installation, users are required to install the “anaconda” meta package from the “conda” package manager:

Install Anaconda on Ubuntu 24.04 q

To install the “anaconda” meta package, simply use the “conda install anaconda” command:

conda install anaconda
Install Anaconda on Ubuntu 24.04 r

After installing the package, now you can update the package.

How to Remove Anaconda From Ubuntu 24.04

To uninstall the Anaconda from Ubuntu 24.04, follow the following steps:

Step 1: Install “anaconda-clean” Package

First, install the “anaconda-clean” package that is used to remove Anaconda’s configuration files:

conda install anaconda-clean -y
Install Anaconda on Ubuntu 24.04 s

Step 2:  Remove Anaconda’s Configurations

Then, execute the package to remove the Anaconda’s configurations:

anaconda-clean -y
Install Anaconda on Ubuntu 24.04 t

Step 3: Remove Anaconda

Lastly, remove the Anaconda by removing its installation directory. In the below command, the “-rf” option will remove the directory recursively and forcefully:

sudo rm -rf anaconda3
Install Anaconda on Ubuntu 24.04 u

That is all about the installation, removal, and use of Anaconda.

Conclusion

To install Anaconda on Ubuntu 24.04, first, download the latest Anaconda installer script from the official website. Then, execute the script by using the “sh <path to Anaconda Installer Script>”. Complete the on-screen instructions and install Anaconda. To update the Anaconda on Ubuntu, utilize the “conda update anaconda” command. In order to uninstall the Anaconda from Ubuntu 24.04, first, remove the Anaconda configurations by using the “anaconda-clean” package, then remove the Anaconda’s installation directory.