Python
Python is one of the most widely used programming languages in scientific computing, and it is well supported on Hábrók. This page describes the recommended way to use Python on the cluster, from loading the right Python version, to managing packages and environments, to running Python jobs and working interactively.
What is different about Python on the cluster?
On your own laptop, you might install Python packages directly with pip install or mamba install , but on the cluster things work a little differently:
- Python is provided through the module system, which gives you access to several different versions of Python as well as a number of pre-built, performance-optimised libraries. You should always start by loading a Python module rather than relying on any system Python.
- You cannot install packages globally, instead, you manage your own isolated environments in your personal directories.
- You can use the pre-installed library modules (such as SciPy-bundle, TensorFlow, PyTorch, etc.) rather than installing these yourself via pip or mamba, since the cluster-provided versions are compiled and optimised for the hardware.
- However, these cannot be mixed with user-installed Pythong packages. If your workflow also needs additional Python packages beyond the pre-installed library modules, it's best to install them all yourself with pip, uv, or mamba.
The pages in the following section walk you through all of this in detail.
Quick links
Loading Python
How to find and load Python versions on Hábrók using the module system. Also covers the pre-installed optimised libraries (numpy, scipy, TensorFlow, PyTorch, etc.) and how to check what is already available before installing anything yourself.
Python Environments
On the cluster you work in isolated Python environments. This subsection covers the three main tools for creating and managing these environments:
- pip + venv — The standard Python approach. Built into Python itself, no extra installation needed. Recommended for most users who just need to install a set of Python packages.
- uv — A modern, fast alternative to pip + venv that also handles project management.
- Mamba — An alternative to Anaconda, which itself is a separate environment and package manager that can also manage non-Python dependencies. While installation instructions are available, we generally discourage its use on Hábrók and recommend using pip + venv or uv instead.
Running Python Jobs
How to write job scripts that use your Python environment on the cluster. Covers single-CPU jobs, multi-CPU jobs using multiprocessing, GPU jobs, and multi-node MPI jobs.
Python in VSCode
How to use Python modules in VScode.
Jupyter Notebooks
How to run Jupyter notebooks on Hábrók, either through the web portal or via an SSH tunnel to a compute node running a batch job.
Spyder
How to install and run Spyder, a graphical Python IDE for scientific work, using a remote desktop session on the web portal.
Python FAQs
My program output does not appear as expected when I submit a job.
There are two possibilities here. First; your program is not reaching the line where you expect to output something, this is something you will have to solve yourself and preferably test on a local machine. Second; python has buffered your output, then an unexpected crash ate the buffer. This makes debugging certain programs on Hábrók very tough because you might have produced some output but it is not shown because of the way Python handles output to the terminal or in this case the .job file. The easiest solution is to run python with the -u flag, so python -u <my_script> <other_arguments>. There are also some solutions including logging and outputting to stderr instead of stdout.