How to Install Anaconda on Debian 12

Updated on January 17, 2025
How to Install Anaconda on Debian 12 header image

Introduction

Install Anaconda on Debian 12 to utilize an open-source distribution of Python and R, designed for data science, machine learning, and scientific computing. Anaconda includes Conda, a powerful package and environment manager, along with various scientific libraries for processing large-scale data and performing advanced computations. It is an ideal platform for building machine learning models and executing complex computations on a server.

This article explains how to install Anaconda on Debian 12 and manage Conda environments to run multiple packages on a server.

Install Anaconda On Debian 12

Anaconda is not available in the default package repositories on Debian 12. Follow the steps below to download the latest installation script and install Anaconda on your Debian server.

  1. Install all required dependency packages for Anaconda.

    console
    $ sudo apt-get install libgl1-mesa-glx libegl1-mesa libxrandr2 libxrandr2 libxss1 libxcursor1 libxcomposite1 libasound2 libxi6 libxtst6 -y
    
  2. Visit the Anaconda repository, and download the latest installation script for Linux. For example, Anaconda3-2024.10-1-Linux-x86_64.sh.

    console
    $ wget -O anaconda.sh https://repo.anaconda.com/archive/Anaconda3-2024.10-1-Linux-x86_64.sh
    
  3. Test the integrity of the downloaded Anaconda installation script.

    console
    $ shasum -a 256 anaconda.sh
    

    Verify that the generated hash value matches the installer's SHA256 value in the Anaconda repository similar to the one below.

    3ba0a298155c32fbfd80cbc238298560bf69a2df511783054adfc151b76d80d8
  4. Run the script using Bash to install Anaconda on Debian server.

    console
    $ bash anaconda.sh
    
    • Press Enter when prompted to start the installation and review the Anaconda license agreement.

      Welcome to Anaconda3 2024.10-1
      In order to continue the installation process, please review the license
      agreement.
      Please, press ENTER to continue
      >>>
    • Press Space to review the Anaconda terms of service, and press Q to close the pager.

    • Enter yes when prompted to accept the license terms and press Enter to install Anaconda to the default location in your user's home directory.

      Do you accept the license terms? [yes|no]
      >>> yes
      
      Anaconda3 will now be installed into this location:
      /home/linuxuser/anaconda3
      - Press ENTER to confirm the location
      - Press CTRL-C to abort the installation
      - Or specify a different location below
      
      [/home/linuxuser/anaconda3] >>>
    • Enter yes and press Enter when prompted to update your shell profile and initialize Conda to activate it in every session.

      Do you wish to update your shell profile to automatically initialize conda?
      This will activate conda on startup and change the command prompt when activated.
      If you'd prefer that conda's base environment not be activated on startup,
      run the following command when conda is activated:
      
      conda config --set auto_activate_base false
      
      You can undo this by running `conda init --reverse $SHELL`? [yes|no]
      [no] >>> yes

      Your output should be similar to the one below when the installation is successful.

      .....................
      modified      /home/linuxuser/.bashrc
      
      ==> For changes to take effect, close and re-open your current shell. <==
      
      Thank you for installing Anaconda3!
  5. Reload your shell configuration to apply the Anaconda changes.

    console
    $ source ~/.bashrc
    

    Verify that your shell prompt changes to the default base Conda environment.

    console
    (base) linuxuser@vultr~$
    
  6. View the installed Conda version.

    console
    $ conda --version
    

    Output:

    conda 24.9.2
  7. View information about the active Conda environment, Python version, and channels.

    console
    $ conda info
    

    Your output should be similar to the one below.

    active environment : base
    active env location : /home/linuxuser/anaconda3
            shell level : 1
       user config file : /home/linuxuser/.condarc
    populated config files : /home/linuxuser/anaconda3/.condarc
          conda version : 24.9.2
    conda-build version : 24.9.0
         python version : 3.12.7.final.0
       base environment : /home/linuxuser/anaconda3  (writable)
      conda av data dir : /home/linuxuser/anaconda3/etc/conda
           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 : /home/linuxuser/anaconda3/pkgs
                          /home/linuxuser/.conda/pkgs
       envs directories : /home/linuxuser/anaconda3/envs
                          /home/linuxuser/.conda/envs
               platform : linux-64

If you use an Ubuntu 24.04 server, you can follow this guide to install Anaconda on Ubuntu 24.04 and set up its environment for data science, machine learning, and scientific computing tasks.

Install Anaconda for Multiple Users

Anaconda is installed and available in your active user's home directory with a default base environment. To enable multiple users to use Anaconda and manage Conda environments, create a new dedicated anaconda group, and grant it ownership privileges to the Anaconda installation directory. Follow the steps below to create the anaconda group, add users to the group, and enable read permissions to the Anaconda installation directory.

  1. Switch to your user's home directory.

    console
    $ cd
    
  2. Create a new anaconda group.

    console
    $ sudo groupadd anaconda
    
  3. Grant the anaconda group ownership privileges to the Anaconda installation directory.

    console
    $ sudo chgrp -R anaconda /home/linuxuser/anaconda3/
    
  4. Grant the owner and the anaconda group full privileges to the Anaconda installation directory.

    console
    $ sudo chmod 770 -R /home/linuxuser/anaconda3/
    
  5. Add your active user to the anaconda group. Replace linuxuser with your actual user.

    console
    $ sudo usermod -a -G anaconda linuxuser
    
  6. Create a new user such as exampleuser.

    console
    $ sudo adduser exampleuser
    
  7. Add the user to the anaconda group.

    console
    $ sudo usermod -a -G anaconda exampleuser
    
  8. Switch to the new user.

    console
    $ su - exampleuser
    

    Enter the user's password when prompted to log in.

  9. Activate the base Conda environment in the user's session.

    console
    $ source /home/linuxuser/anaconda3/bin/activate
    
  10. Initialize Conda in the user's environment.

    console
    $ conda init
    

    Your output should be similar to the one below.

    no change     /home/linuxuser/anaconda3/shell/condabin/Conda.psm1
    no change     /home/linuxuser/anaconda3/shell/condabin/conda-hook.ps1
    no change     /home/linuxuser/anaconda3/lib/python3.12/site-packages/xontrib/conda.xsh
    no change     /home/linuxuser/anaconda3/etc/profile.d/conda.csh
    modified      /home/exampleuser/.bashrc
  11. Reload the user's shell configuration to apply the changes.

    console
    $ source ~/.bashrc
    

    Verify that your shell prompt changes to the default base Conda environment.

    console
    (base) exampleuser@vultr~$
    
  12. View the installed Conda version to ensure the user can manage Conda environments.

    console
    $ conda --version
    

    Output:

    conda 24.9.2
  13. Press Ctrl + D to switch back to your previous user's session.

Manage Conda Environments

Conda environments isolate specific resources including packages, versions, and dependencies for projects on your server. A single Conda environment is active at a time and activating another environment automatically deactivates the active environment. Follow the steps below to create and activate Conda environments to manage specific packages on your server.

  1. Create a new myenv Conda environment.

    console
    $ conda create -n myenv
    
    • Enter y and press Enter when prompted to create the myenv environment.

      Proceed ([y]/n)? y

      Output:

      Preparing transaction: done
      Verifying transaction: done
      Executing transaction: done
      #
      # To activate this environment, use
      #
      #     $ conda activate myenv
      #
      # To deactivate an active environment, use
      #
      #     $ conda deactivate
  2. Activate the myenv environment.

    console
    $ conda activate myenv
    
  3. Verify that your shell prompt changes from base to the myenv environment.

    console
    (myenv) $
    
  4. Install new packages such as numpy and pandas in the myenv environment.

    console
    $ conda install numpy pandas=2.0 scipy
    
  5. Update packages in the Conda environment. For example, update the pandas package to the latest version.

    console
    $ conda update pandas
    
  6. Remove a Conda package from the active environment. For example, remove the scipy package.

    console
    $ conda remove scipy
    

    Enter y and press Enter when prompted to remove the scipy package.

    Proceed ([y]/n)? y
  7. Remove all unused packages including cached tarballs, index cache, logfiles, and temporary files.

    console
    $ conda clean --all
    

    Enter y and press Enter to confirm and remove the packages when prompted.

    Will remove 525 (1.09 GB) tarball(s).
    Proceed ([y]/n)? y
    
    Will remove 1 index cache(s).
    Proceed ([y]/n)? y
    
    Will remove 16 (165.9 MB) package(s).
    Proceed ([y]/n)? y
    
    There are no tempfile(s) to remove.
    There are no logfile(s) to remove.

    If you receive a file permissions error, ensure that your active user has full privileges to the pkgs subdirectory in the Anaconda installation directory.

  8. Export the active Conda environment to a file such as environment.yml.

    console
    $ conda env export > environment.yml
    
  9. Create a new Conda environment such as myenv-2 using the exported environment file.

    console
    $ conda env create -f environment.yml -n myenv-2
    
  10. List all available Conda environments.

    console
    $ conda env list
    

    Your output should be similar to the one below. The active environment is marked with an asterisk (*).

    base                     /home/linuxuser/anaconda3
    myenv                 *  /home/linuxuser/anaconda3/envs/myenv
    myenv-2                  /home/linuxuser/anaconda3/envs/myenv-2

Run Applications in a Conda Environment

Jupyter Notebook is an open-source application for interactive computing that uses computational notebooks and supports multiple programming languages. Follow the steps below to install and run Jupyter Notebook as a sample application in the active myenv environment.

  1. Install the latest jupyter package.

    console
    $ conda install jupyter
    
  2. List all installed packages in your environment and verify that the jupyter package is available.

    console
    $ conda list -n myenv
    

    Output:

    jupyter                   1.0.0           py312h06a4308_9
    jupyter-lsp               2.2.0           py312h06a4308_0
    jupyter_client            8.6.0           py312h06a4308_0
    jupyter_console           6.6.3           py312h06a4308_1
    jupyter_core              5.7.2           py312h06a4308_0
    jupyter_events            0.10.0          py312h06a4308_0
    jupyter_server            2.14.1          py312h06a4308_0
  3. Run the following command to create a sample hello.ipynb Jupyter notebook that outputs a Greetings from Vultr message.

    console
    $ echo '{
     "cells":[
      {
         "cell_type":"code",
         "execution_count":2,
         "id":"5acd64e3-b2bc-41b0-8fc1-1666cb479f30",
         "metadata":{
    
         },
         "outputs":[
            {
               "name":"stdout",
               "output_type":"stream",
               "text":[
               ]
            }
         ],
         "source":[
            "msg=\"Greetings from Vultr!\"\n",
            "print(msg)"
         ]
      },
      {
         "cell_type":"raw",
         "id":"7ed9e62d-6bc3-4116-b0e9-1b06814cc5f2",
         "metadata":{
    
         },
         "source":[
    
         ]
      }
     ],
     "metadata":{
      "kernelspec":{
         "display_name":"Python 3 (system-wide)",
         "language":"python",
         "name":"python3"
      },
      "language_info":{
         "codemirror_mode":{
            "name":"ipython",
            "version":3
         },
         "file_extension":".py",
         "mimetype":"text/x-python",
         "name":"python",
         "nbconvert_exporter":"python",
         "pygments_lexer":"ipython3",
         "version":"3.10.12"
      }
     },
     "nbformat":4,
     "nbformat_minor":5
    }' > hello.ipynb
    
  4. Run the hello.ipynb notebook and write the output to a new hello.nbconvert.ipynb file.

    console
    $ jupyter nbconvert --to notebook --execute hello.ipynb
    

    Output:

    [NbConvertApp] Converting notebook hello.ipynb to notebook
    [NbConvertApp] Writing 1175 bytes to hello.nbconvert.ipynb
  5. Print the hello.nbconvert.ipynb file and verify that a Greetings from Vultr! message displays in the outputs cell.

    console
    $ cat hello.nbconvert.ipynb
    

    Output:

    {
     "cells":[
      {
         ...
         "outputs":[
            {
               "name":"stdout",
               "output_type":"stream",
               "text":[
                  "Greetings from Vultr!\n"
               ]
            }
         ],
         "source":[
            "msg=\"Greetings from Vultr!\"\n",
            "print(msg)"
         ]
      }
      ...
    }  
  6. Deactivate the myenv environment to switch back to the default base environment.

    console
    (myenv) $ conda deactivate
    

    Output:

    console
    (base) $
    

Conclusion

You have installed Anaconda on a Debian 12 server and set up a Conda environment to manage packages. You can use Conda to create multiple isolated environments to install and manage Python packages based on your project needs. For more information and environment options, visit the Anaconda documentation.