Back to All Articles
Server Python HPC Cluster

How-To: Install any Python Version on HU-Cluster

Martin Eberlein · January 16, 2023 · 5 min read

You decided to run your latest research software tool not locally on your laptop, but instead on the mighty Humboldt-Universität Berlin Compute Cluster? Good choice! These powerful machines provide the perfect environment to test, build, and benchmark research software.

However, research tools frequently depend on specific Python versions and packages. Unfortunately, since you share these cluster nodes with other students and department members, root privileges are not provided. If your experiment deadline is tomorrow and you need Python 3.10 while the system provides 3.8, what can you do?

Here is the solution: pyenv. This quick tutorial walks through installing, updating, and effortlessly switching between any Python version in your user space without root access.

Connecting to the HU Compute Cluster requires an active Humboldt-Universität account or an account from the Computer Science department. If you are configuring a different shared server, the pyenv steps below work identically.

1. Connect to the Cluster

From your local terminal, connect to your assigned compute server via SSH:

ssh -l <hu_cs_account> <server>.informatik.hu-berlin.de

Alternatively, connect using your primary university email alias:

ssh -l <hu_account>@hu-berlin.de <server>.informatik.hu-berlin.de

2. Install Pyenv in User Space

Run the official Pyenv installation script, which clones into ~/.pyenv:

curl https://pyenv.run | bash

3. Configure Your Shell Environment

Add Pyenv initialization commands to your shell profile so that shims and paths are loaded automatically on login.

For Bash users:

echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init -)"' >> ~/.bashrc

echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.profile
echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.profile
echo 'eval "$(pyenv init -)"' >> ~/.profile

For Zsh users:

echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc
echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc
echo 'eval "$(pyenv init -)"' >> ~/.zshrc

Restart your current shell session to apply the changes:

exec $SHELL

Verify that Pyenv is active:

pyenv --version

4. Install and Switch Python Versions

You can now install any Python release without needing root rights:

# Install Python 3.10.9
pyenv install 3.10.9

# List all installed versions
pyenv versions

Set a system-wide user default:

pyenv global 3.10.9

Or lock a specific research repository to a local version (creating a .python-version file):

cd ~/projects/my-experiment
pyenv local 3.10.9

Summary

With Pyenv configured in your user directory, you can build virtual environments, install modern Python releases, and reproduce experimental benchmarks without relying on cluster administrators. Happy experimenting!

Martin Eberlein

Martin Eberlein

Incoming Security Software Engineer at Google & Doctoral Researcher at Humboldt-Universität zu Berlin specializing in automated debugging and software security.

Back to All Articles