
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.
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
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
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.
3ba0a298155c32fbfd80cbc238298560bf69a2df511783054adfc151b76d80d8Run 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
yeswhen 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
yesand 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] >>> yesYour 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!
Reload your shell configuration to apply the Anaconda changes.
console$ source ~/.bashrc
Verify that your shell prompt changes to the default
baseConda environment.console(base) linuxuser@vultr~$
View the installed Conda version.
console$ conda --version
Output:
conda 24.9.2View 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.
Switch to your user's home directory.
console$ cd
Create a new
anacondagroup.console$ sudo groupadd anaconda
Grant the
anacondagroup ownership privileges to the Anaconda installation directory.console$ sudo chgrp -R anaconda /home/linuxuser/anaconda3/
Grant the owner and the
anacondagroup full privileges to the Anaconda installation directory.console$ sudo chmod 770 -R /home/linuxuser/anaconda3/
Add your active user to the
anacondagroup. Replacelinuxuserwith your actual user.console$ sudo usermod -a -G anaconda linuxuser
Create a new user such as
exampleuser.console$ sudo adduser exampleuser
Add the user to the
anacondagroup.console$ sudo usermod -a -G anaconda exampleuser
Switch to the new user.
console$ su - exampleuser
Enter the user's password when prompted to log in.
Activate the
baseConda environment in the user's session.console$ source /home/linuxuser/anaconda3/bin/activate
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/.bashrcReload the user's shell configuration to apply the changes.
console$ source ~/.bashrc
Verify that your shell prompt changes to the default
baseConda environment.console(base) exampleuser@vultr~$
View the installed Conda version to ensure the user can manage Conda environments.
console$ conda --version
Output:
conda 24.9.2Press 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.
Create a new
myenvConda environment.console$ conda create -n myenv
Enter
yand press Enter when prompted to create themyenvenvironment.Proceed ([y]/n)? yOutput:
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
Activate the
myenvenvironment.console$ conda activate myenv
Verify that your shell prompt changes from
baseto themyenvenvironment.console(myenv) $
Install new packages such as
numpyandpandasin themyenvenvironment.console$ conda install numpy pandas=2.0 scipy
Update packages in the Conda environment. For example, update the
pandaspackage to the latest version.console$ conda update pandas
Remove a Conda package from the active environment. For example, remove the
scipypackage.console$ conda remove scipy
Enter
yand press Enter when prompted to remove thescipypackage.Proceed ([y]/n)? yRemove all unused packages including cached tarballs, index cache, logfiles, and temporary files.
console$ conda clean --all
Enter
yand 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
pkgssubdirectory in the Anaconda installation directory.Export the active Conda environment to a file such as
environment.yml.console$ conda env export > environment.yml
Create a new Conda environment such as
myenv-2using the exported environment file.console$ conda env create -f environment.yml -n myenv-2
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.
Install the latest
jupyterpackage.console$ conda install jupyter
List all installed packages in your environment and verify that the
jupyterpackage 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_0Run the following command to create a sample
hello.ipynbJupyter notebook that outputs aGreetings from Vultrmessage.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
Run the
hello.ipynbnotebook and write the output to a newhello.nbconvert.ipynbfile.console$ jupyter nbconvert --to notebook --execute hello.ipynb
Output:
[NbConvertApp] Converting notebook hello.ipynb to notebook [NbConvertApp] Writing 1175 bytes to hello.nbconvert.ipynbPrint the
hello.nbconvert.ipynbfile and verify that aGreetings from Vultr!message displays in theoutputscell.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)" ] } ... }Deactivate the
myenvenvironment to switch back to the defaultbaseenvironment.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.