If needed, users are recommended to install Python packages in their own home directory. This allows users to easily switch between versions of Python libraries and applications for different projects. This also avoids potential conflicts. You may use the ‘pip’ command to install python packages locally.
Please use this tutorial ONLY if all of your python projects require the same set of python packages (i.e. one python environment works for all projects). Otherwise, if multiple different python environments are needed, please contact Research Service at researchservices@bc.edu to get instructions on how to install python packages locally with miniconda.
- Load the python module and check the versions of ‘python’ and ‘pip’. Make sure that python and pip are on the same version.
[johnchris@andromeda ~]$ interactive
Executing: srun --pty -N1 -n1 -c4 --mem=8g -pinteractive -t0-04:00:00 /bin/bash
Press any key to continue or ctrl+c to abort.
(press any key)
srun: job 585396 queued and waiting for resources
srun: job 585396 has been allocated resources
cpu-bind=MASK - c004, task 0 0 [946829]: mask 0x888800000000 set [johnchris@c004 ~]$ module load miniconda
[johnchris@c004 ~]$ python --version
Python 3.12.4
[johnchris@c004 ~]$ pip --version
pip 24.2 from /m31/modules/miniconda/3/lib/python3.12/site-packages/pip (python 3.12)
[johnchris@c004 ~]$
- Install the python package(s) you need (numpy)
[johnchris@c004 ~]$ pip install numpy
Defaulting to user installation because normal site-packages is not writeable
Collecting numpy
Downloading numpy-2.3.1-cp312-cp312-manylinux_2_28_x86_64.whl.metadata (62 kB)
Downloading numpy-2.3.1-cp312-cp312-manylinux_2_28_x86_64.whl (16.6 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 16.6/16.6 MB 86.2 MB/s eta 0:00:00
Installing collected packages: numpy
Successfully installed numpy-2.3.1
- If needed, you can check the ‘list’ of installed packages
[johnchris@c004 ~]$ pip list
Package Version
------------------------ ---------
anaconda-anon-usage 0.4.4
archspec 0.2.3
boltons 23.0.0
Brotli 1.0.9
…
- To run a job on Andromeda using the set of packages you have installed locally, see the following slurm file example
#!/bin/bash
#SBATCH --job-name=sample # Job name
#SBATCH --partition=short # Partition CPU node to run your job on
#SBATCH --time=01:00:00 # Time limit (hrs:min:sec,max 120 hours)
#SBATCH --ntasks=1 # Number of tasks
#SBATCH --nodes=1 # Number of nodes requested
#SBATCH --cpus-per-task=1 # Number of CPU processors per task
#SBATCH --mem-per-cpu=4G # Memory per CPU
#SBATCH --mail-type=ALL # Mail events (NONE, BEGIN, END, FAIL, ALL)
#SBATCH --mail-user=your_username@bc.edu #Email for notifications
module load miniconda
cd /home/your_username/your_python_project_directory
python your_python_script.py