Installing Anaconda on Ubuntu 24.04

Anaconda is an essential tool for data scientists and developers working in Python and R. It simplifies package management and deployment, offering a collection of over 1500 data science packages. This guide provides detailed steps to install Anaconda on Ubuntu 24.04, including setting up environments and basic usage.

In this tutorial you will learn:

  • Downloading and Installing Anaconda
  • Completing the Installation Process
  • Setting up the Environment
  • Understanding and Managing Anaconda Environments
  • Testing the Installation with a Simple Python Script
Installing Anaconda on Ubuntu 24.04
Installing Anaconda on Ubuntu 24.04

Installation Steps

The following steps will guide you through the process of installing Anaconda on your Ubuntu 24.04 system.

  1. Downloading the Anaconda Installer
    Visit the Anaconda website and download the latest version of Anaconda for Linux. The installer file will typically be named like Anaconda3-2023.09-0-Linux-x86_64.sh.
  2. Running the Installation Script
    Open a terminal, navigate to the download directory, and execute the script:

    $ bash Anaconda3-2023.09-0-Linux-x86_64.sh

    Follow the on-screen instructions to accept the license agreement and confirm installation settings.

  3. Completing the Installation
    The installation process will unpack and install Anaconda. During the process, choose to initialize Anaconda by updating your shell profile, enabling automatic activation of the base environment.

    Successful Anaconda installation on Ubuntu 20.04
    Successful Anaconda installation on Ubuntu 20.04
  4. Setting Up the Environment
    Restart your terminal or source the .bashrc file to refresh the environment variables:

    $ source ~/.bashrc

    After this, you should see a (base) prefix in your terminal, indicating the base Anaconda environment is active.



  5. Understanding Anaconda Environments
    Anaconda allows the creation of isolated environments for different projects. The (base) environment is the default, but you can create and activate new environments as needed. To deactivate the base environment automatically on terminal startup, run:

    $ conda config --set auto_activate_base false

    To activate an environment manually, use:

    $ conda activate <env_name>

    To list installed anaconda environments run:

    $ conda env list

    To return to the base environment:

    $ conda activate base
    

    Remember that you need to restart your terminal or source the .bashrc file to refresh the environment variables.

  6. Testing with a Simple Python Program
    To test your installation, create a simple Python script, hello_world.py, with the content:

    $ print("Hello, World!")

    Run the script in the Anaconda environment:

    $ python hello_world.py

    Successful output confirms a functional Anaconda installation.

Conclusion

Congratulations! You have successfully installed Anaconda on Ubuntu 22.04. This powerful platform is now ready for your data science and machine learning projects. With the knowledge of managing environments, you can maintain organized, efficient workflows and manage dependencies effectively for each project.