Custom environments and packages¶
Your notebook server starts from a prebuilt image that already includes common scientific libraries. You can add to it in a few ways, depending on whether you need the change to survive a server restart.
Install into your home directory (persists)¶
Packages installed into your home directory survive restarts, because the
home directory is persistent. With pip, install for your user:
A more reliable approach is a dedicated environment under your home
directory, for example with conda/mamba or a Python virtual
environment, so your project's dependencies are reproducible and isolated:
python -m venv ~/envs/myproject
source ~/envs/myproject/bin/activate
pip install -r requirements.txt
Register the environment as a Jupyter kernel so you can select it from the notebook interface:
Install for the session only (does not persist)¶
A plain pip install some-package (without --user and outside a
home-directory environment) works for the current session but is lost
when the server stops, because it writes outside your home directory.
Use this only for quick experiments.
Custom images¶
For dependencies that are awkward to install at runtime (system libraries, compiled tools, large frameworks), the better option is a custom server image baked with everything preinstalled, offered as a server profile. Provisioning custom images is an administrator task; talk to your administrator or Sunet about adding one to your hub.