In order to be able to install new Python packages and make your work reproducible, please use virtual environments.
There is more than one way to create a private environment in Python.
This page describes the installation of packages on /scratch. One has to remember, though, that files stored in the HPC scratch file system are subject to the HPC Scratch old file purging policy: Files on the /scratch file system that have not been accessed for 60 or more days will be purged (read more).
Thus you can consider the following options
Reinstall your packages if some of the files get deleted
You can do this manually
You can do this automatically. For example, within a workflow of a pipeline software like Nextflow
Pay for "Research Project Space" - read more here
Use Singularity and install packages within a corresponding overlay file - read more here
It is advisable to create private environment inside the project directory. This boosts reproducibility and does not use space in /home/$USER
virtualenv is a tool to create isolated Python environments
Since Python 3.3, a subset of it has been integrated into the standard library under the venv module.
Note: you may need to install virtualenv first, if it is not yet installed (instructions)
Now create new virtual environment in current directory
Empty
OR
inherit all packages from those installed on HPC already (and available in PATH after you load python module)
venv is package shipped with Python3. It provides subset of options available in virtualenv tool (link).
python3 -m venv venvCreate new virtual environment in current directory
Empty
OR
inherit all packages from those installed on HPC already (and available in PATH after you load python module)
If you have activated a virtual environment, you can exit it with the following command:
deactivateWhen you use this env in sbatch script, please use
module purge;If you use mpi
mpiexec bash -c "module purge;