JupyterHub extension install help

I am having trouble installing the nbgitpuller extension, for all users, which I suspect is due to my JupyterHub configuration. I would appreciate if someone could take a look and let me know where I am going wrong.

Here is my current setup

$ /opt/jupyterhub/bin/python3 /opt/jupyterhub/bin/jupyterhub --version
4.0.2
$ /opt/jupyterhub/bin/jupyter --paths
config:
    /opt/jupyterhub/etc/jupyter
    /home/ubuntu/.jupyter
    /usr/local/etc/jupyter
    /etc/jupyter
data:
    /opt/jupyterhub/share/jupyter
    /home/ubuntu/.local/share/jupyter
    /usr/local/share/jupyter
    /usr/share/jupyter
runtime:
    /home/ubuntu/.local/share/jupyter/runtime

I have previously successfully installed the onedarkpro extension using these steps…

$ /opt/conda/envs/python/bin/python -m pip install --ignore-installed ~/jupyterlab_onedarkpro-0.1.0-py3-none-any.whl

$ cp -r /opt/conda/envs/python/share/jupyter/labextensions/jupyterlab_onedarkpro/ /opt/jupyterhub/share/jupyter/labextensions/jupyterlab_onedarkpro/

However when I try to install nbgitpuller using the same command, I don’t see it’s folder in /opt/conda/envs/python/share/jupyter/labextensions

$  /opt/conda/envs/python/bin/python -m pip install --ignore-installed nbgitpuller

Jupyter labextension also reports nbgitpuller as not being installed…

$ sudo /opt/jupyterhub/bin/jupyter labextension list
JupyterLab v4.0.7
/opt/jupyterhub/share/jupyter/labextensions
        jupyterlab_pygments v0.2.2 enabled  X (python, jupyterlab_pygments)
        jupyterlab_onedarkpro v0.1.0 enabled OK (python, jupyterlab_onedarkpro)
        @jupyter-widgets/jupyterlab-manager v5.0.9 enabled OK (python, jupyterlab_widgets)


   The following extensions are outdated:
        jupyterlab_pygments
        
   Consider checking if an update is available for these packages.

Doing a file search I can see the python pkg installed but that is it…
/opt/conda/envs/python/lib/python3.8/site-packages/nbgitpuller

Am I wrong to assume that all pip installed extensions result in a folder in /opt/conda/envs/python/share/jupyter/labextensions/ ?
And if so how can I get Jupyter to recognise the extension in the site-packages folder?

nbgitpuller needs to be installed in the Python environment used for your singleuser server, i.e. wherever jupyterhub-singleuser is running from. By default this will be the same as your JupyterHub environment (/opt/jupyterhub/) but it doesn’t have to be, it’s common to use a separate user environment so packages can be managed independently.

The other thing to be aware of is that pip may automatically install to a local user’s folder instead of the system folder if the permissions aren’t correct. Most commonly this occurs if the system folder is owned by root but you’re running pip as a normal user.

If that’s not enough to get it working can you:

  • share your full JupyterHub configuration
  • tell us how you installed JupyterHub, and how it’s run
1 Like

Thank you @manics.
Each user has their own conda environment that is used as the default kernel. With other extensions I was able to install them in JupyterHub in the user & python environment used by jupyterhub itself, but it sounds like nbgitpuller may have to be installed for each user in their own environment which is something I was trying to avoid.

JupyterHub was installed following this guide.
I skipped the Nginx reverse proxy steps, as we use a proxy external to the server.

Here’s the config files…

/opt/jupyterhub/etc/jupyterhub/jupyterhub_config.py

c = get_config()  #noqa
c.JupyterHub.data_files_path = '/opt/JupyterHub_customtemplates'
c.JupyterHub.ip = '0.0.0.0'
c.JupyterHub.template_paths = ['/opt/JupyterHub_customtemplates/templates_external']
c.Spawner.cmd = ['/opt/JupyterHub_customtemplates/custom_startup.sh']
c.Spawner.default_url = '/lab'
c.Spawner.env_keep = ['PATH', 'PYTHONPATH', 'CONDA_ROOT', 'CONDA_DEFAULT_ENV', 'SPARK_HOME', 'HADOOP_HOME', 'SPARK_CLASSPATH']
c.LocalProcessSpawner.shell_cmd = ['bash', '-l', '-c']

The custom startup script
/opt/JupyterHub_customtemplates/custom_startup.sh

#!/bin/bash

jupyter lab workspaces import /opt/JupyterHub_customtemplates/workspace.json
exec jupyterhub-singleuser "$@"

JupyterHub is run as a service on an ubuntu server.
/etc/systemd/system/jupyterhub.service

[Unit]
Description=JupyterHub
After=syslog.target network.target

[Service]
User=root
Environment="PATH=/opt/conda/condabin:/opt/conda/envs/python/bin:/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/opt/jupyterhub/bin"
ExecStart=/opt/jupyterhub/bin/jupyterhub -f /opt/jupyterhub/etc/jupyterhub/jupyterhub_config.py --debug

[Install]
WantedBy=multi-user.target

I found the cause. nbgitpuller is a jupyter server extension not a lab extension, hence it was not showing up in the extensions list