Hi all,
I am trying to set JupyterHub so that each user group can choose from a different set of available preconfigured packages. I figured out this might be done via venv’s (one for each group), but there are some issues. I installed the new venv, jupyterhub sees it and allows to create a new kernel. So far so good. However, any packages that are installed in that venv are not available from jupyterhub when that venv (kernel) is active.
To install venv:
python -m venv python_ai
sudo python -m ipykernel install --name=python_ai
To install package:
source python_ai/bin/activate
pip install actionrules-lukassykora
Package is installed and available when Python is run from venv in terminal:
source python_ai/bin/activate
python
from actionrules.actionRulesDiscovery import ActionRulesDiscovery
However, when I use the python_ai kernel from JupyterHub, the same python import statement returns Not found error:
It looks like the venv is registered with jupyterhub but jupyterhub does not know that is should look for packages in the venv directory.
To support this: when packages are installed from Jupyter Hub (web interface) they are placed to
['/opt/tljh/user/lib/python3.9/site-packages']
as determined from the UI using import site; site.getsitepackages()
However, when one is in the activated virtual environment accessed through the terminal, the result of import site; site.getsitepackages()
is: ['/home/jupyter-...@.../python_ai/lib/python3.9/site-packages']
Which is different from what is shown when the same command is executed from the python_ai
kernel in jupyterhub UI (as shown on the screenshot above).
The contents of usr/local/share/jupyter/kernels/python_ai/kernel.json is
> {
> "argv": [
> "/opt/tljh/user/bin/python",
> "-m",
> "ipykernel_launcher",
> "-f",
> "{connection_file}"
> ],
> "display_name": "python_ai",
> "language": "python",
> "metadata": {
> "debugger": true
> }
I tried to include as much information as possible, but I am not sure I am on the right path.
Any help is appreciated.