Python and Jupyter

This page will address some common pitfalls when working with python and related tools on a shared system like a cluster.

The following topics will be discussed in detail on this page:

Available python versions

All unix systems come with a system wide python installation, however for the cluster it is highly recommended to use one of the anaconda installations provided as a modules.
# reminder
module avail python
module load python/XY
These modules come with a wide range of preinstalled packages.

Installing packages with pip

Pip is a package manager for python it can be used to easily install packages and manage their versions.
By default pip will try to install packages system wide, which will not be possible due to missing permissions.
The behaviour can be changed by adding --user to the call.
pip install --user package-name

By defining the variable PYTHONUSERBASE (best done in your bashrc/bash_profile) we change the installation location from ~/.local to a different path. Doing so will prevent your home folder from cluttering with stuff that does not need a backup and hitting the quota.
export PYTHONUSERBASE=$WOODYHOME/software/privat

Conda envirenment

Some scientific software comes in form of a Conda environment (e.g.
By default such an environment will be installed to ~/.conda. However the size can be several GB therefore you should configure Conda to a different path. This will prevent your home folder from hitting the quota. It can be done by following these steps:

conda config # create ~/.condarc
Add the following lines to the file (replace the path if you prefer a different location)
- ${WOODYHOME}/software/privat/conda/pkgs
- ${WOODYHOME}/software/privat/conda/envs
You can check that this configuration file is properly read by inspecting the output of conda info
For more options see

Jupyter notebook security

When using Jupyter notebooks with their default configuration a hashed password will be visible in your terminal.
We can change this with a few configuration steps by adding a password protection.

First generate a configuration file by executing
jupyter notebook --generate-config

Open a python terminal and generate a password
from notebook.auth import passwd; passwd()

Add the password hash to your notebook config file
# The string should be of the form type:salt:hashed-password.

c.NotebookApp.password = u''
c.NotebookApp.password_required = True

From now on your notebook will be password protected this comes also with the benefit that you can use bash funktions for a more convinient use.

Quick reminder how to use the remote notebook
#start notebook on a frontend (e.g. woodycap3)
jupyter notebook --no-browser --port=XXXX

on your client:
ssh -f -L YYYY:localhost:XXXX -N
Open the notebook in your local browser at https://localhost:YYYY
With XXXX and YYYY being 4 diget numbers.
Don’t forget to stop the notebook once you are done. Otherwise you will block resources that could be used by others!

Some useful functions/alias for lazy people 😉

alias remote_notebook_stop='ssh username@remote_server_ip "pkill -u username jupyter"'
Be aware this will kill ALL jupyter processes that you own!

nohup ssh -J -L $1:localhost:$1 " . /etc/bash.bashrc.local; module load python/3.7-anaconda ; jupyter notebook --port=$1 --no-browser" ;echo ""; echo " the notebook can be started in your browser at: https://localhost:$1/ " ; echo ""


nohup ssh -J -L $1:localhost:$1 " . /etc/profile; module load python/3.7-anaconda ; jupyter notebook --port=$1 --no-browser" ;echo ""; echo " the notebook can be started in your browser at: https://localhost:$1/ " ; echo ""


If you are using a cshell remove . /etc/bash.bashrc.local and . /etc/profile from the functions.