Versionen im Vergleich

Schlüssel

  • Diese Zeile wurde hinzugefügt.
  • Diese Zeile wurde entfernt.
  • Formatierung wurde geändert.

...

Jupyter allows you to work in your own virtual environment using the Python modules installed on the HPCconda. Start by loading the Python interpreter/module you want to work with, e.g.creating a new conda environment:

Codeblock
module load PythonMiniconda/3.10.5

...

1
conda create -p /gpfs/project/$USER

...

Codeblock
python -m venv --prompt py310 --system-site-packages /py310 python=3.10
conda activate /gpfs/project/$USER/py310

PIP_CONFIG_FILE=/software/python/pip.conf pip install --user --upgrade pip setuptools wheel

Hint: it may be neccessary to install virtualenv as a user if this fails:  PIP_CONFIG_FILE=/software/python/pip.conf pip install --user virtualenv

Activate this environment and install all packages you want to work with - at least ipykernel must be installed

Hint: this only works if you have defined a .condarc with channels pointing to our repo server (see link)

Install the programs that you need with conda install , at least  ipykernel must be installed:

Codeblock
conda 
Codeblock
source /gpfs/project/$USER/py310/bin/activate

PIP_CONFIG_FILE=/software/python/pip.conf pip install ipykernel

Create a new file "kernel.sh" in the main directory of your environment and make it executable

Codeblock
cd /gpfs/project/$USER/py310
vi kernel.sh

kernel.sh
----------------------------------------------------
#!/bin/bash
module load Python/3.10.5
source export PYTHONHOME=/gpfs/project/$USER/py310/lib/python3.10/site-packages
export PATH=/gpfs/project/$USER/py310/bin/activate:$PATH
exec python -m ipykernel $@
----------------------------------------------------

chmod a+x kernel.sh

...

Create a new file "kernel.json" with contents (!!replace $USER with your explicit username here!!)

Codeblock
{
"argv": [
  "/gpfs/project/$USER/py310/kernel.sh",
  "-f",
  "{connection_file}"
 ],
 "display_name": "Venv (py310)",
 "language": "python",
 "metadata": {
  "debugger": true
 }
}

In your next jupyterhub session a new kernel with the name "venv (py311py310)" will then be available.

Hint: This seems to only work with Python versions < 3.11 !