Attention

Following the recent operating system upgrade, software listings and module load commands now reflect the upgraded system. Some examples and notices are still being updated and may contain outdated guidance.

Conda

Conda manages environments containing Python and other software dependencies. Use it when your project needs packages or non-Python dependencies supplied by Conda channels. The Anaconda module provides Conda on Stanage.

For ordinary Python projects and environments using HPC module-provided packages such as mpi4py, see Python on Stanage.

Loading Conda

After connecting to Stanage (see Establishing a SSH connection), start an interactive session with the following command:

srun --pty bash -i

Anaconda Python can be loaded with one of the following:

module load Anaconda3/2025.06-1
module load Anaconda3/2024.02-1
module load Anaconda3/2022.10
module load Anaconda3/2022.05
module load Anaconda3/2021.11
module load Anaconda3/2020.11
module load Anaconda3/2019.07

The shared base Conda environment includes Python and other packages. Create your own environment to install or change packages; do not modify the shared installation.

Initialise Conda’s shell functions after loading the module:

source "$EBROOTANACONDA3/etc/profile.d/conda.sh"

This enables conda activate and conda deactivate in the current shell, including batch jobs, without running conda init.

Creating a Conda Environment

These examples explicitly select conda-forge. --override-channels prevents other configured channels from being used for these commands.

Conda environments share files with the package cache using hard links where possible; copies may be required when the cache and environment are on different filesystems.

To create an environment with Python 3.13, NumPy and pip you can run:

conda create --override-channels --channel conda-forge -n mynumpy python=3.13 numpy pip

This installs compatible Python 3.13 and NumPy packages and creates an environment named mynumpy.

You can request specific versions of Python and packages, provided they are available from conda-forge:

conda create --override-channels --channel conda-forge -n myscience python=3.13 numpy scipy pip

If you wish to modify an existing environment, such as one of the anaconda installations, you can clone that environment:

conda create --override-channels --channel conda-forge --clone myscience -n myexperiment

This will create an environment called myexperiment which has all the same conda packages as the myscience environment.

How to avoid large conda environments filling up your home directory

Home directories have limited space and can often reach their quota limit. Conda environments exponentionally take up space, if you have or want to create one or more large Conda environments (e.g. containing bulky Deep Learning packages such as TensorFlow or PyTorch) then there’s a risk you’ll quickly use up your home directory’s storage quota.

To avoid this, build your conda environments in a fastdata area

  1. Create a .condarc file in your home directory if it does not already exist.

  2. Add an envs_dirs: and pkgs_dirs: section to your .condarc file as shown below:

pkgs_dirs:
- /mnt/parscratch/users/$USER/anaconda/.pkg-cache/

envs_dirs:
- /mnt/parscratch/users/$USER/anaconda/.envs
  1. We recommend users create their own personal folder in the /fastdata area. As this doesn’t exist by default, you can create it with safe permissions. See fastdata area

  2. Then create .envs and .pkg-cache directories in your fastdata area as shown below:

mkdir -p /mnt/parscratch/users/$USER/anaconda/.pkg-cache/  /mnt/parscratch/users/$USER/anaconda/.envs

Installations of environments and package caching should now occur in your fastdata area

Using conda Environments

Once the conda module is loaded you have to load or create the desired conda environments. For the documentation on conda environments see the conda documentation.

You can load a conda environment with:

conda activate myexperiment

where myexperiment is the name of the environment, and unload one with:

conda deactivate

which will return you to the previous environment.

It is possible to list all the available environments with:

conda env list

Installing Packages Inside a Conda Environment

Once you have activated your own environment you can install additional packages or different versions of packages into it. There are two methods for doing this, conda and pip, if a package is available through conda it is strongly recommended that you use conda to install packages. You can search for packages using conda:

conda search --override-channels --channel conda-forge pandas

then install the package using:

conda install --override-channels --channel conda-forge pandas

if you are not in your environment you will get a permission denied error when trying to install packages, if this happens, create or activate an environment you own.

If a package is not available through Conda, search for it on PyPI and install it in your activated environment:

python -m pip install colormath

Install Conda packages first, then use pip for any remaining packages.

Using Conda and Python in a batch job

Create an example batch submission script called myscript.slurm that is similar to the following:

#!/bin/bash
#SBATCH --ntasks=1
#SBATCH --time=10:00
#SBATCH --mem=2G

export SLURM_EXPORT_ENV=ALL
module load Anaconda3/2025.06-1
source "$EBROOTANACONDA3/etc/profile.d/conda.sh"

# We assume that the conda environment 'myexperiment' has already been created
conda activate myexperiment
srun python mywork.py

Then submit this to Slurm by running:

sbatch myscript.slurm

Further Conda Python Learning Resources

The resources and training courses below may be of interest:

Installing a personal copy of miniconda

Personal Miniconda installation

Miniconda is a free, minimal installer for Conda. It is a small bootstrap version of Anaconda that includes only Conda, Python, their dependencies, and a small number of other useful packages such as pip and zlib.

After connecting to Stanage (see Establishing a SSH connection), start an interactive session with the following command:

srun --pty bash -i

The latest miniconda releases will be made available at https://www.anaconda.com/docs/getting-started/miniconda/main

On Stanage you should install miniconda to your home directory, e.g., $HOME/software/installs/miniconda.

Download the installer:

wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh

Check the sums match with those listed on the downloads page :

sha256sum Miniconda3-latest-Linux-x86_64.sh

Make the file executable:

chmod +x Miniconda3-latest-Linux-x86_64.sh

Create a directory for the installation:

mkdir -p $HOME/software/installs

Run the installer and choose $HOME/software/installs/miniconda as the installation target.

./Miniconda3-latest-Linux-x86_64.sh

After accepting the licence agreement enter the path for the installation:

$HOME/software/installs/miniconda

Caution

Ensure you do not initialise Miniconda as this will interfere with loading other Anaconda modules on the cluster.

Make a modules directory for yourself:

mkdir $HOME/modules

Make a module file for the install you just made:

nano $HOME/modules/miniconda.lua

With content as follows:

         ------------------------------------------------------------------------------------------------
         -- ~/modules/miniconda.lua:
         ------------------------------------------------------------------------------------------------

         help([[
         Description
         ===========
         Makes my personal Miniconda install available.

         More information
         ================
         - Homepage: https://www.anaconda.org
         ]])

         -- Describe the module.
         whatis("Description: Makes my personal Miniconda install available.")
         whatis("Homepage: https://docs.anaconda.com/miniconda")
         whatis("URL: https://www.anaconda.org")

         conflict("Anaconda3")

         local HOME = os.getenv("HOME")
         local MINICONDA_DIR = HOME .. "/software/installs/miniconda"
         setenv("MINICONDA_DIR", MINICONDA_DIR)

         -- Add directories to environment variables.
         prepend_path("PATH", pathJoin(MINICONDA_DIR, "bin"))

Note: Anaconda3 and Miniconda conflict with each other. Do not load Anaconda3 after loading Miniconda. The conflict("Anaconda3") line prevents Miniconda from being loaded when Anaconda3 is already loaded.

Warning

Module files are written in LUA not bash. See Making software available via a custom module file.

Make your custom modules available:

module use $HOME/modules

To skip doing the above everytime you login, you can add this line to the .bashrc file in your home directory:

echo "module use $HOME/modules" >> ~/.bashrc

Assuming the module file is named miniconda, you can load it with:

module load miniconda

Warning

Initialise the shell functions before using conda activate or conda deactivate.

To activate the base environment:

source "$MINICONDA_DIR/etc/profile.d/conda.sh"
conda activate base

Installation notes

Anaconda3

Anaconda3 was installed using Easybuild, build details can be found in $EBROOTANACONDA3/easybuild with a given module loaded.