How to install a JupyterLab extension for all JupyterHub users?

Hello! I would really appreciate help with installing a JupyterLab extension for all JupyterHub users. I’ve read various threads including this but (aside from using Lab) it seems my environment is configured differently.

We are using Ubuntu 22.04 LTS, with JupyterHub being run as a service by root (ExecStart=/root/.pyenv/shims/jupyterhub -f /etc/jupyterhub/ The file has no modifications to env variables.

As root, running jupyter labextension list shows the extension installed:

Other labextensions (built into JupyterLab)
app dir: /root/.pyenv/versions/3.10.4/share/jupyter/lab
@wuxinextcode/jupyterlab-notebookparams v3.1.0 enabled OK

As root, running jupyter lab path gives the following:

Application directory: /root/.pyenv/versions/3.10.4/share/jupyter/lab
User Settings directory: /root/.jupyter/lab/user-settings
Workspaces directory: /root/.jupyter/lab/workspaces

We are using LocalProcessSpawner. As a JupyterLab user, running jupyter lab path gives:

Application directory: /usr/local/share/jupyter/lab
User Settings directory: /home/some-user/.jupyter/lab/user-settings
Workspaces directory: /home/some-user/.jupyter/lab/workspaces

Also as the user, running jupyter labextension list does not show the extension. And which jupyter gives /usr/local/bin/jupyter.

From other threads, I believe my problem is related to these configured paths, but I can’t quite find the answer online. Can I somehow configure JupyterHub to spawn JupyterLab instances that utilize one common configuration with the installed extension? TIA!

still unsolved, but I’ve found that I can change JUPYTERLAB_DIR in the config file, so I created a separate python virtual environment in /opt (accessible to users), installed JupyterLab, and sought to set JUPYTERLAB_DIR to be the path of the /lab dir in that Jupyter installation. Not certain as JUPYTERLAB_DIR is only briefly mentioned once in the docs.

However, a new error appeared on installing the extension with `/opt/jupyterhub/bin/jupyter labextension install “@wuxinextcode/jupyterlab-notebookparams”:

UserWarning: ValueError: "@wuxinextcode/jupyterlab-notebookparams"
is not a valid npm package. 

Installed with jupyterlab==4.0.0. The error didn’t happen earlier but I’m installing the extension the same way, so I believe the cause is something I’m currently overlooking.

EDIT: this issue was resolved by updating npm, but my initial question still stands. If anyone knows how to solve this, TIA!

The easiest option is probably to create a single shared user environment, e.g. /opt/user/venv, and configure jupyterhub to launch /opt/user/venv/bin/jupyterhub-singleuser

1 Like