In this tutorial, we'll explain how to install Anaconda on Ubuntu 24.04.
Anaconda is an open-source distribution of Python and R programming languages, designed for data science, machine learning, and scientific computing. It simplifies package management and deployment, making it an essential tool for developers and data scientists. This tutorial provides a step-by-step guide to installing Anaconda on Ubuntu 24.04.
Understanding Anaconda
Anaconda includes:
- Conda: A powerful package, environment manager, and distribution system.
- Pre-installed Libraries: Tools like NumPy, pandas, Matplotlib, and SciPy are included for convenience.
- Anaconda Navigator: A GUI for managing packages and environments.
- Jupyter Notebook: An interactive environment for coding in Python.
Anaconda enables efficient management of Python versions and packages by creating isolated environments. This prevents conflicts between different dependencies and applications.
How to Install Anaconda on Ubuntu 24.04
Step 1: Update Your System
To ensure compatibility and security, update the package lists and upgrade the installed packages:
sudo apt update && sudo apt upgrade -y
After the upgrade, restart your system if necessary:
sudo reboot
Step 2: Install Dependencies
Before we proceed further, we need to install dependencies. These dependencies are recommended by official Anaconda documentation.
apt-get install libxrandr2 libxrandr2 libxss1 libxcursor1 libxcomposite1 libxi6 libxtst6 -y
Step 3: Download and Install Anaconda
Visit the official Anaconda download page and copy the link for the latest Linux version of Anaconda.
Alternatively, use wget to download the installer directly:
curl -O https://repo.anaconda.com/archive/Anaconda3-2024.10-1-Linux-x86_64.sh
Verify the Installer
Before running the installer, verify its integrity by comparing the SHA256 checksum:
Check the checksum of the downloaded file:
sha256sum Anaconda3-<latest-version>-Linux-x86_64.sh
Compare the output with the checksum provided on the Anaconda website. This step ensures the file has not been tampered with.
Run the Installer
Execute the installer script:
bash Anaconda3-2024.10-1-Linux-x86_64.sh
Follow the prompts:
- Press Enter to review the license agreement.
- Type yes to agree to the terms.
- Specify the installation location or press Enter to use the default (
~/anaconda3
).
Step 4: Initialize Anaconda
After installation, initialize Anaconda to integrate it with your shell:
~/anaconda3/bin/conda init
This modifies your shell configuration file (e.g., .bashrc or .zshrc) to activate the base Conda environment automatically upon login.
Reload your shell:
source ~/.bashrc
Step 5: Test the Installation
Verify that Anaconda is installed and configured correctly:
Check the version:
conda --version
Output:
conda 24.9.2
Confirm that the base environment is activated:
conda info
The output should display information about your Conda installation and active environment.
active environment : base
active env location : /root/anaconda3
shell level : 1
user config file : /root/.condarc
populated config files : /root/anaconda3/.condarc
conda version : 24.9.2
conda-build version : 24.9.0
python version : 3.12.7.final.0
solver : libmamba (default)
virtual packages : __archspec=1=x86_64_v4
__conda=24.9.2=0
__glibc=2.39=0
__linux=6.8.0=0
__unix=0=0
base environment : /root/anaconda3 (writable)
conda av data dir : /root/anaconda3/etc/conda
conda av metadata url : None
channel URLs : https://repo.anaconda.com/pkgs/main/linux-64
https://repo.anaconda.com/pkgs/main/noarch
https://repo.anaconda.com/pkgs/r/linux-64
https://repo.anaconda.com/pkgs/r/noarch
package cache : /root/anaconda3/pkgs
/root/.conda/pkgs
envs directories : /root/anaconda3/envs
/root/.conda/envs
platform : linux-64
user-agent : conda/24.9.2 requests/2.32.3 CPython/3.12.7 Linux/6.8.0-48-generic ubuntu/24.04.1 glibc/2.39 solver/libmamba conda-libmamba-solver/24.9.0 libmambapy/1.5.8 aau/0.4.4 c/. s/. e/.
UID:GID : 0:0
netrc file : None
offline mode : False
Step 6: Update Anaconda
To ensure you have the latest version of Conda and its packages, update Anaconda:
conda update conda
conda update anaconda
Step 7: Using Conda Environments
Conda allows you to create and manage isolated environments for different projects:
Create a new environment:
conda create --name myenv python=3.12
Replace myenv
with your desired environment name and 3.12
with the Python version.
Activate the environment:
conda activate myenv
Deactivate the environment:
conda deactivate
Remove an environment:
conda remove --name myenv --all
Step 8: Installing Packages with Conda
You can install, update, or remove packages easily:
Install a package:
conda install package_name
Update a package:
conda update package_name
Remove a package:
conda remove package_name
Additional Tips
Miniconda: If you only need Conda without the additional libraries, consider installing Miniconda.
Anaconda Navigator: Launch the GUI with:
anaconda-navigator
Environment Export: Share environments with others:
conda env export > environment.yml
Environment Import: Recreate an environment:
conda env create -f environment.yml
Conclusion
You’ve successfully installed and configured Anaconda on Ubuntu 24.04. With Anaconda, you can manage Python environments and dependencies efficiently, enhancing your productivity in data science and development projects. Explore its vast ecosystem of tools, and happy coding!
Checkout our instant dedicated servers and Instant KVM VPS plans.