Python, Conda#
We recommend the usage of our Python modules that provide a Conda installation with a wide range of preinstalled packages and the Conda package manager. See Conda environments on how to configure Conda on our systems.
We discourage the usage of the system-wide installed Python on our systems as it is rather old.
Using Python/Conda#
- List available Python versions:
-
Load the default Python module:
Note: the version of the default Python module might change over time. -
Load a specific Python version:
Installing packages#
Install or build packages inside an interactive job on the target cluster
Install or build packages using an interactive job on the target cluster (Alex, Fritz, TinyGPU, Woody) to make sure GPU support and hardware features can be used properly. Make sure to load modules that might be needed by your Python code, e.g. CUDA/CUDNN for GPU support.
Some of our cluster nodes cannot directly connect to the internet and require a proxy to be configured. In your shell on the compute node enter:
Installing packages via pip
#
pip
is a package manager for Python. By default pip
will install packages system
wide, which will fail due to missing permissions.
Packages can be installed locally by adding --user
:
Inside a Jupyter notebook use:
This command also configures the usage of a proxy through the --proxy
flag.
Alternatively create a conda/venv environment into which you install your packages.
Adjusting installation path of packages#
By default packages installed through pip
or distutils
with the --user
flag
are installed under the $HOME
directory. As quota on $HOME
is scarce and
we regularly backup and snapshot $HOME
it makes sense, to install
packages on a filesystem without backup, like $WORK
.
The installation path for pip
and distutils
can be changed by setting the
environment variable PYTHONUSERBASE
.
To install packages that do not need to be backed up into $WORK
run:
$WORK/software/private
.
To change the installation path permanently add the code snippet to your
~/.bashrc
on the clusters.
Sharing packages and environments with coworkers#
If you intend to share the packages/environments with your coworkers consider wrapping the python package inside a module. For information on the module system see your HPC-Cafe from March 2020.
Setup and define the target folder with environment variable PYTHONUSERBASE
.
Install the package as above. Your module file needs to add to PYTHONPATH
the site-packages
folder and to PATH
the bin
folder, if the package
comes with binaries.
For an example see the module quantumtools
on woody.
Related topics#
- Creating and managing Python virtual environments
- Using Jupyter Notebook
- Our JupyterHub instances