Springe direkt zu Inhalt

Python

Introduction

Python is an interpreted, universal higher programming language.

Caution! In the following, the concept module is on the one hand used in the sense of a Python module, such as, say, numpy, which one can import into a Python program.  On the other hand module also refers to a so-called environment module, with which one can load a specific version of a specific piece of software, either in the terminal or in a shell script, in order to make this available.

Python Modules

When one loads a specific version of Python by loading the corresponding environment module via module add, as well as the standard Python modules a number of commonly used modules, such as regex, pathlib2 oder glob2 will also be made available.

Other Python modules are provided as separate environment modules:

Environment Module Python Module
SciPy-bundle numpy, scipy, pandas, mpi4py
matplotlib matplotlib

Local Python Modules

Many modules are installed automatically with Python and others are available via separate environment modules.  If however a certain Python module is missing, one can install this in one's own home-directory, the best way being to use a virtual environment (venv).

Caution! Intstalling within a batch job does not usually work.  Therefore the installation should be performed once directly on the login node.

First the desired version of Python needs to be loaded, the virtual environment created and then activated.  After this modules can be installed using pip:

module add Python/3.9.5-GCCcore-10.3.0
python -m venv ~/path/to/new/virtual/environment
source ~/path/to/new/virtual/environment/bin/activate
pip install some_module