Jupyter not honouring single user 'defaultUrl' and will not launch into Lab

Hey everyone,

Note that this question is also on Stack Overflow, but reposted here as no one was able to help after a few days (I can’t link to the question though as only two links are allowed).

I’ve recently updated to chart version 2.0.0 of JupyterHub (app version 3.0.0) from JupyterHub’s Helm chart repository.

In the previous version that I was running (0.9.1), I was able to change the default URL so that JupyterLab was loaded by default. However, in the new version that is not working. Note however that I can manually change the URL and JupyterLab loads as expected.

singleuser:
  defaultUrl: /lab

Looking at the Zero to JupyterHub documentation, it states that JupyterLab is the default for JupyterHub 2.0 and Helm chart 2.0, so one would expect JupyterLab to be the default. However, to be sure I tried the both examples in the documentation.

With this example, an error occurs when spawning my server.

singleuser:
  defaultUrl: "/lab"
  extraEnv:
    JUPYTERHUB_SINGLEUSER_APP: "jupyter_server.serverapp.ServerApp"

Traceback (most recent call last):
  File “/opt/conda/bin/jupyterhub-singleuser”, line 7, in
    from jupyterhub.singleuser import main
  File “/opt/conda/lib/python3.8/site-packages/jupyterhub/singleuser/init.py”, line 5, in
    from .app import main
  File “/opt/conda/lib/python3.8/site-packages/jupyterhub/singleuser/app.py”, line 16, in
    App = import_item(JUPYTERHUB_SINGLEUSER_APP)
  File “/opt/conda/lib/python3.8/site-packages/traitlets/utils/importstring.py”, line 30, in import_item
    module = import(package, fromlist=[obj])
ModuleNotFoundError: No module named ‘jupyter_server’

With this example, nothing changes.

singleuser:
  defaultUrl: "/lab"
  extraEnv:
    JUPYTERHUB_SINGLEUSER_APP: "notebook.notebookapp.NotebookApp"

How can I launch into JupyterLab by default?

1 Like

It sounds like your singleuser image is too old. Can you try rebuilding it with the latest version of JupyterLab and JupyterHub?

If that doesn’t work can you share a minimal example Dockerfile with us that exhibits the problem?

Thanks for your reply. That is indeed the case, and using the latest jupyter/scipy-notebook image ( c77245e2acbc) does allow us to launch into JupyterLab by default.

However, it comes with a different version of Python (3.10.9 vs 3.8.6), and due to the ‘unique’ way in which we have to validate our development environments, I can’t use that image.

Is there anyway I can amend my Dockerfile (partial file below) to install the jupyter_server module, or is it simply not an option for older images?

Dockerfile

FROM jupyter/scipy-notebook:703d8b2dcb88

ARG AUDITBEAT_FILENAME=auditbeat-oss-7.12.1-amd64.deb
RUN wget https://artifacts.elastic.co/downloads/beats/auditbeat/$AUDITBEAT_FILENAME -O $AUDITBEAT_FILENAME && \
    dpkg -i $AUDITBEAT_FILENAME && \
    rm $AUDITBEAT_FILENAME && \
    wget https://github.com/tianon/gosu/releases/download/1.12/gosu-amd64 -O /usr/bin/gosu && \
    chmod +x /usr/bin/gosu

COPY entrypoint /entrypoint

ENTRYPOINT [ "/entrypoint/entrypoint.sh" ]
CMD ["jupyter", "lab"]

entrypoint

#!/bin/bash

my_uid=$(id -u)
echo "Started entrypoint.sh with UID $my_uid"

if [[ $my_uid == 0 ]]; then
    echo "Waiting for auditbeat to start .."
    /etc/init.d/auditbeat start
    until /usr/sbin/service auditbeat status | grep -q "auditbeat is running"
    do
        sleep 1
    done
    echo "auditbeat is running"
else
    echo "Not running as root, cannot start auditbeat - exiting"
    exit 1
fi

exec gosu "$NB_USER" "$@"

You can can try running conda install ...., similar to how the original 703d8b2dcb88 image was built:

Make sure you update jupyterhub too.

Note more recent versions of the image use the faster mamba instead of conda

Tanks @manics, I will take a look and give it a bash when I get some time.

Thanks,
David