Anaconda
Anaconda allows users to manage Python packages and create isolated environments for projects without modifying the system-wide Python installation on the cluster. This ensures that different projects can use different Python versions and libraries without conflicts.
To view the available Anaconda versions please visit the Available Modules page.
Creating a Basic Environment
Warning
When creating an environment or installing packages, you must be connected to a compute node.
For more information on obtaining an interactive session, click here.
To create a new environment with a specific Python version:
conda create -n myenv python=3.11
To activate the environment:
conda activate myenv
Installing Packages
Once the environment is created and activated, packages can be installed using one of the following methods:
- Install with pip (Recommended)
Packages can be installed directly using pip. This is the recommended method.
pip install packageName
- Install with conda
Packages can also be installed using conda from the default Anaconda channels.
conda install packageName
Warning
Due to recent licensing changes, some uses of Anaconda’s package channels may require a paid license.
To avoid potential issues, use pip within your environment whenever possible.
Listing and Managing Environments
To list all Conda environments available:
conda env list
To deactivate the current environment:
conda deactivate
To remove an environment:
conda remove -n myenv --all
Exporting and Importing Environments
To export an environment to a file:
conda env export > environment.yml
To recreate an environment from a file:
conda env create -f environment.yml
Using Anaconda Inside a Slurm Script
To use an Anaconda environment inside a Slurm job, load the Anaconda module and activate the environment within the job script.
#!/bin/bash
#SBATCH --time=01:00:00
#SBATCH --cpus-per-task=4
#SBATCH --mem=8G
module load anaconda/anaconda-2024.10
conda activate myenv
python script.py