Python and Conda
Python is available on the system already pre-installed, with the typical packages such as Numpy and SciPy. It is used by simply typing 'python3' (this is version 3.9.19).
$ which python3
/usr/bin/python3
$ python3 --version
Python 3.9.19
There's also a slightly newer version, 3.11, available by typing
python3.11
If you need a lot of additional packages, or some built-in enhancements, or the latest Python and packages, installing your own copy might be best (although, really, most are available via 'modules'). See below!
Anaconda Python (recommended option)
Anaconda is available via a module on the POD. Anaconda is one of the options that lets users easily install relevant packages in their home directories. For example, if you want another Python package (things like scipy, matplotlib, etc.) , you can install it straight away yourself rather than having to ask Paul and Fuz.
Use the Anaconda module and activate the base environment.
$ module load anaconda/3.13
$ source activate base
Once you've done this, you're using your own version of python (3.13 in this case).
If you want to install a package, for example, 'MatPlotLab', simply install it with 'pip'
Creating Conda Virtual Environment
In Anaconda, an environment is a separate space where packages and dependencies can be installed independently, without affecting other environments. To create a basic environment without any packages, run the command below:
$ conda create --name my_env_1
You can activate it with the "conda activate my_env_1" command to activate the specific environment.
$ conda activate my_env_1
Next, let's add the specific packages from the Anaconda repository to the environment named my_env_1.
$ conda install pytorch==2.0.0 torchvision==0.15.0 torchaudio==2.0.0 cpuonly -c pytorch
These packages will be installed into the currently activated environment (my_env_1).
To run a job in the queue, you can write a simple script
#!/bin/bash
#SBATCH -N 1 -n 1
cd $SLURM_SUBMIT_DIR
module load anaconda/3.13
source activate my_env_1
python myfile.py