Conda & Python
For Python and environments, we offer the modules
miniforge3
- CPython
The environment base
is installed system-wide and cannot be modified.
The old module anaconda3
is no longer supported. Please switch to another module.
We discourage users from using the module miniconda3
because the “default” channel requires a paid license for more than 200 employees (including doctoral research positions) and outside of class room usage.
You use this module at your own risk!
Loading the module and preparing an environment
We recommend using source activate
instead of conda init
.
This way, the .bashrc is not updated and the environment is not loaded at each login, reducing unnecessary load on the systems and making your login much faster.
In order to use Python and Conda environments, load the module miniforge3
and create an environment.
We strongly suggest you create this environment on the scratch file system using the prefix option.
This example loads the module, creates a new environment called myenv
on the scratch file system linked to the variable $WORK
, loads python3.12, and activates it using the source command.
module load miniforge3
conda create --prefix $WORK/ -n myenv python=3.12 conda
source activate $WORK/myenv
Once this is done, you are able to use Python normally, as you would on a personal computer with commands such as
conda install -y numpy scipy matplotlib
pip install pillow
Do not use the conda install
command after you have installed a package using pip
! This will create inconsistencies in the environment.
Better to install all packages using conda
and only run pip
as the last command.
Loading the environment in a batch script
You repeat the steps for loading the environment manually in your batch script.
This includes the source command and the path.
Be careful with the path and the partition selection because the variable $WORK
points to different locations (as detailed in Storage System and specifically Scratch/Work page).
module load miniforge3
source activate $WORK/myenv
Updating environments
We do not recommend updating environments. It is safer to recreate them from zero as soon as you have to use new or different packages.
Many packages offer a file with the list of required packages and versions, which you can use to set up a new environment. The same goes for packages you always need. Simply create a requirements file and use that one to set up fresh environments every time you need to change something. Remember to delete the old one.