Installing and Configuring Anaconda on Ubuntu 24.04: A Detailed Guide

anaconda

In the world of scientific computing and data analysis, Python has emerged as a leading programming language due to its versatility and rich ecosystem of libraries. However, managing the dependencies of these libraries across diverse environments can be challenging. This is where Anaconda, a popular Python distribution, proves to be a game-changer.

This article explores Anaconda’s capabilities, its role in simplifying dependency management, and how it integrates seamlessly with Python-based scientific libraries.

The article will be consist of several section, namely :

  1. What Is Anaconda?
  2. Core Python-Based Scientific Libraries in Anaconda
  3. Dependency Management Made Easy
  4. Advantages of Using Anaconda for Scientific Computing
  5. How To Install Anaconda on Ubuntu 24.04 LTS
  6. Managing Conda Environment

    What Is Anaconda?

    Anaconda is an open-source distribution of Python and R programming languages, specifically designed for scientific computing, data science, machine learning, and big data applications. It provides a robust platform that simplifies the management of libraries, dependencies, and virtual environments, making it an essential tool for researchers and developers.

    Key features of Anaconda include:

    •  Conda Package Manager**: Handles the installation, upgrade, and removal of libraries and dependencies.
    • Integrated Development Environment (IDE)**: Comes with Jupyter Notebook, Spyder, and other tools.
    • Cross-Platform Compatibility**: Available for Windows, macOS, and Linux.

    Core Python-Based Scientific Libraries in Anaconda

    Anaconda includes a vast collection of pre-installed scientific libraries, saving users the hassle of manual setup. Here are some key libraries:

    1. NumPy
    NumPy is the cornerstone of scientific computing in Python. It provides support for large multidimensional arrays and matrices, along with a collection of mathematical functions to operate on them.

    2. Pandas
    Pandas is indispensable for data manipulation and analysis. It introduces data structures like DataFrames, which are intuitive and powerful for handling structured data.

    3. Matplotlib and Seaborn
    Matplotlib is a comprehensive library for creating static, interactive, and animated visualizations. Seaborn builds on Matplotlib, offering high-level interface designs for statistical graphics.

    4. Scikit-Learn
    Scikit-learn provides simple and efficient tools for predictive data analysis. It includes implementations of machine learning algorithms, such as classification, regression, and clustering.

    5. SciPy
    SciPy extends NumPy’s functionality with modules for optimization, integration, interpolation, and other scientific computing tasks.

    6. TensorFlow and PyTorch
    These are powerful libraries for deep learning and neural network development, enabling advanced machine learning solutions.

    7. SymPy
    For symbolic mathematics, SymPy offers tools for algebraic computation, solving equations, and more.

    Dependency Management Made Easy

    One of Anaconda’s standout features is its ability to manage dependencies effectively. Here’s how:

    1. Virtual Environments:

    Anaconda allows you to create isolated environments where libraries and dependencies are installed without affecting the global setup. For example:

    conda create -n myenv python=3.9 numpy pandas
    conda activate myenv

    2. Conflict Resolution:
    Using the Conda package manager, Anaconda resolves version conflicts between dependencies automatically, ensuring a smooth installation process.

    3. Reproducibility:
    Environment specifications can be exported and shared using a YAML file:

    conda env export > environment.yml
    conda env create -f environment.yml

    Advantages of Using Anaconda for Scientific Computing

    1. All-in-One Platform:
    Anaconda bundles Python, scientific libraries, and an IDE, eliminating the need for multiple installations.

    2. User-Friendly Interface:
    Tools like Anaconda Navigator provide a graphical interface to manage environments, install libraries, and launch applications.

    3. Performance Optimization:
    Many of the libraries included in Anaconda are optimized for performance, making computations faster and more efficient.

    4. Community Support:
    With an active community of developers and researchers, Anaconda provides extensive documentation and forums for troubleshooting.

    How To Install Anaconda on Ubuntu 24.04 LTS

    On this stage we show you how to install Anaconda on Ubutnu 24.04, the installation will be consist of several stages, namely :

    Step 1: Update the System

    Before starting the installation, update your package manager to ensure everything is up-to-date.

    sudo apt update && sudo apt upgrade -y

    Step 2: Download the Anaconda Installer”

    Visit the Anaconda Downloads Page to get the latest version. We can download the Anaconda source depend on our Operating system type (Windows, Linux or Macintosh).

    Download Anaconda Source from its

    Since we know, if Anaconda is not available in the default Ubuntu package repositories. we will use the command below to download it directly:

    wget https://repo.anaconda.com/archive/Anaconda3-2024.10-1-Linux-x86_64.sh
    Download Anaconda installer from official Anaconda webesite for Linux distribution

    then verify the Anaconda source file by using command line below :

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

    The output is as shown below :

    Checksum of Anaconda installer

    Compare the output with the checksum on the official website.

    Step 3 : Run Anaconda Installer

    Make the script executable and run it:

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

    Follow the prompts during installation:

    1. Press Enter to review the license agreement and type yes to accept it.
    2. Specify the installation location or press Enter to install in the default directory (~/anaconda3).
    Run the Anaconda installer

    Step 4: Activate the Installation

    Once the installation is complete, activate Anaconda by initializing it:

    source ~/.bashrc

    Step 5: Verify the Installation

    The above command has no output. To test the conda installation we submit the command line below:

    conda --version

    or

    conda info
    Verify the conda installation by querying the Conda version

    Managing Conda Environments

    Conda simplifies environment management by allowing you to create, export, list, remove, and update environments, each with its own set of Python versions and packages. Activating an environment enables switching or moving between them effortlessly. Moreover, Conda supports sharing environment configurations through environment files, ensuring reproducibility and collaboration in projects.

    There are numerous options available for the commands outlined on this page. For a comprehensive reference to all available commands, refer to the official commands documentation.

    On this section we will create a simple Conda environments on our Ubuntu 24.04 operating system. Here’s the steps :

    1. Creating new Conda environment

    To create an environment with default version of Python :

     conda create --name <my-env>

    To create an environment with a specific version of Python:

    conda create -n myenv python=3.12

    The sample below is to create a new Conda environment called as bckinfo_env and using Python version 3.12 :

    creating new Conda environment with Pyhton 3.12

    By creating new environment, we have automatically activate its environment, from the sampel above we just already created and activated the new environment called as bckinfo_env.

    2. Specifying a Location For an Environment

    On the example above, we are using default location for Conda environment.

    environment location: /home/ramansah/anaconda3/envs/bckinfo_env

    You can specify where a conda environment is created by providing a path to a target directory during its creation. For example, the following command will create a new environment in a subdirectory named envs within the current working directory:

    conda create --platform osx-64 --name python-x64 python

    3. Creating Simple Application

    On this section, we will create a new simple script to test of our environment was run properly. We will show the message “Hello World, World“. For this purpose we will create a new a simple Python script as shown below :

    conda run -n bckinfo_env python -c "print('Hello World, World 3')"

    The sample script will be shown below :

    Conda Hello World Example

    Conclusion

    We have installed Anaconda on Ubuntu 24.04 and managed Conda environments on the server. Anaconda provides an advanced platform for managing dependency and packages to match your project’s needs. Use Anaconda when running multiple projects that require different packages and dependencies. For more information, please visit the official Anaconda documentation.

    (Visited 68 times, 1 visits today)

    You may also like