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:
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
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
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:
After viewing the “END USER LICENSE AGREEMENT”, you need to accept these terms to continue the installation. Type “yes” and press “Enter” to proceed:
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:
The next prompt will ask you to activate the Anaconda’s “base” environment, press “yes” to activate. This will complete the installation procedure:
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
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:
To download the essential packages in a newly created virtual environment, hit “Y”:
Step 2: Activate the Environment
Now, activate the Anaconda’s environment using the “conda activate <virtual env-name>” command:
conda activate venv
Step 3: Create Python Script
Create a simple Python script in the nano editor through the below command:
sudo nano demo.py
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
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
Step 5: Deactivate Virtual Environment
To deactivate the virtual environment, simply execute the “conda deactivate” command:
conda deactivate
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
Update Anaconda Package
After updating the package manager, now update the “anaconda” package:
conda update anaconda
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:
To install the “anaconda” meta package, simply use the “conda install anaconda” command:
conda install anaconda
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
Step 2: Remove Anaconda’s Configurations
Then, execute the package to remove the Anaconda’s configurations:
anaconda-clean -y
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
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.
Check our LinkedIn company page