Skip to content

Python Using pip Packages

Step 1: Installing Python Packages with pip

Section titled “Step 1: Installing Python Packages with pip”

Load Environment Module: python/3.12

Install Python Package: Numpy

Installation Path (Pip Packages): /home/$USER/.local

To instal python packages with pip, run below command in the SSH terminal (CLI), for tutorial in accessing CLI, please refer to SSH Shell Access to EdUHK HPC Platform and Cluster (Web-based Shell Access)

# Load Python 3.12 Module
$ module load python/3.12
# Check Python Version
$ python -V
# Install Numpy Package:
$ python –m pip install numpy

Step 2: Prepare Python Program Source Code

Section titled “Step 2: Prepare Python Program Source Code”

For the example source code please refer to Python Program Source Code (Example)


Pre-configured template script path → /home/$USER/job_template/slurm_job/numpy_test.sh

Example template script

#!/bin/bash
#SBATCH --job-name=numpy_test ## Job Name
#SBATCH --partition=shared_cpu ## Partition for Running Job
#SBATCH --nodes=1 ## Number of Compute Node
#SBATCH --ntasks-per-node=1 # Number of Task per Compute Node
#SBATCH --cpus-per-task=2 ## Number of CPU per task
#SBATCH --time=60:00 ## Job Time Limit (i.e. 60 Minutes)
#SBATCH --mem=10GB ## Total Memory for Job
#SBATCH --output=./%x%j.out ## Output File Path
#SBATCH --error=./%x%j.err ## Error Log Path
## Initiate Environment Module
source /usr/share/modules/init/profile.sh
## Reset the Environment Module components
module purge
## Load Module
module load python/3.10
## Run user command
python3 /home/${USER}/job_template/python/numpy_test.py
## Clear Environment Module components
module purge

Guides for submitting HPC job, please refer to: HPC Job Submission (For CLI) and HPC Job Submission (For Web Portal)


Step 5: Reset Python (pip) Environment as Default

Section titled “Step 5: Reset Python (pip) Environment as Default”

Guides for Reset Python (pip) Environment as Default, please refer to: How to Reset Customized Python Environment as Default?