"/lab" (JupyterLab) not found on a working JupyterHub installation ("tree" working normally)

Hello, I manage our laboratory server where we have JupyterHub working with traditional notebooks under Apache proxy server under the “Jupyter” folder on a Ubuntu 20.04 server.
It works great.
I am now trying to add JupyterLab instead (or en plus) of “classic” notebooks.
I have added it using pip (as for the rest of the system) and restarted jupyterhub service (sudo systemctl restart jupyterhub) but when I go (manually or by setting c.Spawner.default_url = "/lab" in jupyterhub_config.py) to https://[server]/jupyter/user/[my user]/lab I get a 403 not found error.

What could I have missed ?

In a forum I got to try “# jupyter lab build”, but when I try Iget an error that it requires nodejs >=12.0.0 while my apt-get says “nodejs is already the newest version (10.19.0~dfsg-3ubuntu1)”.
Ok, I have added the repos and installed node 19, “jupyter lab build” now works, but still 403 error on “/lab” :-/

Have you installed JupyterLab into the correct Python environment? What does pip list show? How was JupyterHub installed and configured?

Thank you for your kind reply.

I have only the main Python environment.

root@[XXXX] ~ # pip list
Package                  Version
------------------------ --------------------
acme                     1.1.0
alembic                  1.4.2
anyio                    3.6.2
argon2-cffi              21.3.0
argon2-cffi-bindings     21.2.0
async-generator          1.10
attrs                    19.3.0
Babel                    2.11.0
backcall                 0.2.0
beautifulsoup4           4.11.1
bleach                   3.1.5
blinker                  1.4
certbot                  0.40.0
certbot-apache           0.39.0
certifi                  2019.11.28
certipy                  0.1.3
cffi                     1.15.1
chardet                  3.0.4
charset-normalizer       3.0.1
Click                    7.0
colorama                 0.4.3
ConfigArgParse           0.13.0
configobj                5.0.6
cryptography             2.8
cupshelpers              1.0
cycler                   0.10.0
dbus-python              1.2.16
decorator                4.4.2
defer                    1.0.6
defusedxml               0.6.0
distro                   1.4.0
distro-info              0.23ubuntu1
entrypoints              0.3
ezodf                    0.3.2
fastjsonschema           2.16.2
future                   0.18.2
GDAL                     3.0.4
httplib2                 0.14.0
idna                     2.8
importlib-metadata       6.0.0
ipykernel                5.3.4
ipython                  7.16.1
ipython-genutils         0.2.0
ipywidgets               7.5.1
jedi                     0.17.2
Jinja2                   3.1.2
josepy                   1.2.0
json5                    0.9.11
jsonschema               3.2.0
jupyter                  1.0.0
jupyter-client           7.4.9
jupyter-console          6.1.0
jupyter-core             5.1.4
jupyter-events           0.6.3
jupyter-server           2.1.0
jupyter-server-terminals 0.4.4
jupyter-telemetry        0.1.0
jupyterhub               1.1.0
jupyterlab               3.5.3
jupyterlab-pygments      0.2.2
jupyterlab-server        2.16.6
keyring                  18.0.1
kiwisolver               1.0.1
language-selector        0.1
launchpadlib             1.10.13
lazr.restfulclient       0.14.2
lazr.uri                 1.0.3
lxml                     4.5.0
Mako                     1.1.3
MarkupSafe               2.1.2
matplotlib               3.1.2
mistune                  2.0.4
mock                     3.0.5
more-itertools           4.2.0
nbclassic                0.4.8
nbclient                 0.7.2
nbconvert                7.2.8
nbformat                 5.7.3
nest-asyncio             1.5.6
netifaces                0.10.4
notebook                 6.5.2
notebook-shim            0.2.2
numpy                    1.17.4
oauthlib                 3.1.0
OWSLib                   0.19.1
packaging                23.0
pamela                   1.0.0
pandocfilters            1.4.2
parsedatetime            2.4
parso                    0.7.1
pbr                      5.4.5
pexpect                  4.8.0
pickleshare              0.7.5
Pillow                   7.0.0
pip                      20.3.3
platformdirs             2.6.2
plotly                   4.4.1
prometheus-client        0.8.0
prompt-toolkit           3.0.5
ps-mem                   3.12
psycopg2                 2.8.4
ptyprocess               0.6.0
pycairo                  1.16.2
pycparser                2.21
pycups                   1.9.73
Pygments                 2.14.0
PyGObject                3.36.0
PyJWT                    1.7.1
pymacaroons              0.13.0
PyNaCl                   1.3.0
PyOpenGL                 3.1.0
pyOpenSSL                19.0.0
pyparsing                2.4.6
pyproj                   2.5.0
PyQt5                    5.14.1
pyRFC3339                1.1
pyrsistent               0.15.5
python-apt               2.0.0+ubuntu0.20.4.7
python-augeas            0.5.0
python-dateutil          2.8.2
python-debian            0.1.36ubuntu1
python-editor            1.0.4
python-json-logger       2.0.4
pytz                     2019.3
PyYAML                   5.3.1
pyzmq                    25.0.0
qtconsole                4.7.5
QtPy                     1.9.0
requests                 2.28.2
requests-toolbelt        0.8.0
requests-unixsocket      0.2.0
retrying                 1.3.3
rfc3339-validator        0.1.4
rfc3986-validator        0.1.1
ruamel.yaml              0.16.10
ruamel.yaml.clib         0.2.0
SecretStorage            2.3.1
Send2Trash               1.8.0
setuptools               51.1.2
simplejson               3.16.0
sip                      4.19.21
six                      1.14.0
sniffio                  1.3.0
soupsieve                2.3.2.post1
SQLAlchemy               1.3.18
terminado                0.8.3
testpath                 0.4.4
tinycss2                 1.2.1
tomli                    2.0.1
tornado                  6.2
traitlets                5.8.1
ubuntu-advantage-tools   27.9
ubuntu-drivers-common    0.0.0
urllib3                  1.25.8
wadllib                  1.3.3
wcwidth                  0.2.5
webencodings             0.5.1
websocket-client         1.4.2
wheel                    0.34.2
widgetsnbextension       3.5.1
wxPython                 4.0.7
xkit                     0.0.0
zipp                     1.0.0
zope.component           4.3.0
zope.event               4.4
zope.hookable            5.0.0
zope.interface           4.7.1

root@[XXX] ~ # jupyter serverextension list
config dir: /root/.jupyter
    jupyterlab  enabled 
    - Validating...
      jupyterlab 3.5.3 OK
config dir: /usr/local/etc/jupyter
    jupyterlab  enabled 
    - Validating...
      jupyterlab 3.5.3 OK

I have installed JupyterHub with

pip3 install jupyter
pip3 install jupyterhub
pip3 install jupyterlab

and it runs under an apache proxy server, but not under the root directory, instead it runs under c.JupyterHub.base_url = '/jupyter/'.
If I add c.Spawner.default_url = '/lab' to /etc/jupyterhub_config.py I am correctly redirected to [...]/lab but then I have the 403 error (from Jupyter, not from Apache, I can still see the Jupyter headers).

Solved !! (but downgrading the jupyter server)

By running the jupyterhub by command line I got the stderror where I got this:

[W 2023-01-26 09:56:44.808 SingleUserNotebookApp serverextension:13] Loading JupyterLab as a classic notebook (v6) extension.
[C 2023-01-26 09:56:44.809 SingleUserNotebookApp serverextension:18] You must use Jupyter Server v1 to load JupyterLab as notebook extension. You have v2.1.0 installed.
    You can fix this by executing:
        pip install -U "jupyter-server<2.0.0"
[I 2023-01-26 09:56:44.809 SingleUserNotebookApp singleuser:561] Starting jupyterhub-singleuser server version 1.1.0

By indeed running that command it is now working but… what do I loose by running jupyter-server-1.23.5 instead of jupyter-server-2.1.0 ?

This is a very old version of JupyterHub. Try upgrading all your packages, or (maybe safer) create a new Python environment with the latest versions of everything.

1 Like

sic… I have updated Jupyterhub, and after a few other updates (including the database) I got it working, but only when I run it directly (i.e. # /usr/local/bin/jupyterhub -f /etc/jupyterhub/jupyterhub_config.py) … when I run it under sytemctl I get the following error:

root@lef-nancy ~ # sudo systemctl start jupyterhub 
root@lef-nancy ~ # sudo systemctl status jupyterhub 
● jupyterhub.service - Jupyterhub
     Loaded: loaded (/etc/systemd/system/jupyterhub.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Thu 2023-01-26 16:01:55 CET; 5s ago
    Process: 10405 ExecStart=/usr/local/bin/jupyterhub -f /etc/jupyterhub/jupyterhub_config.py (code=exited, status=1/FAILURE)
   Main PID: 10405 (code=exited, status=1/FAILURE)

janv. 26 16:01:55 lef-nancy systemd[1]: Started Jupyterhub.
janv. 26 16:01:55 lef-nancy jupyterhub[10405]: [I 2023-01-26 16:01:55.498 JupyterHub app:2810] Running JupyterHub version 3.1.0
janv. 26 16:01:55 lef-nancy jupyterhub[10405]: [I 2023-01-26 16:01:55.498 JupyterHub app:2840] Using Authenticator: jupyterhub.auth.PAMAuthenticator-3.1.0
janv. 26 16:01:55 lef-nancy jupyterhub[10405]: [I 2023-01-26 16:01:55.498 JupyterHub app:2840] Using Spawner: jupyterhub.spawner.LocalProcessSpawner-3.1.0
janv. 26 16:01:55 lef-nancy jupyterhub[10405]: [I 2023-01-26 16:01:55.498 JupyterHub app:2840] Using Proxy: jupyterhub.proxy.ConfigurableHTTPProxy-3.1.0
janv. 26 16:01:55 lef-nancy jupyterhub[10405]: [I 2023-01-26 16:01:55.499 JupyterHub app:1649] Loading cookie_secret from /jupyterhub_cookie_secret
janv. 26 16:01:55 lef-nancy jupyterhub[10405]: Found database schema version 4dc2d5a8c53c != 651f5419b74d. Backup your database and run `jupyterhub upgrade-db` to upgrade to the latest schema.
janv. 26 16:01:55 lef-nancy systemd[1]: jupyterhub.service: Main process exited, code=exited, status=1/FAILURE
janv. 26 16:01:55 lef-nancy systemd[1]: jupyterhub.service: Failed with result 'exit-code'.

The “strange” thing is that I did already updated the db with # jupyterhub upgrade-db

My system service is on both nano /lib/systemd/system/jupyterhub.service and /etc/systemd/system/jupyterhub.service:

[Unit]
Description=Jupyterhub

[Service]
User=root
Environment="PATH=/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin"
ExecStart=/usr/local/bin/jupyterhub -f /etc/jupyterhub/jupyterhub_config.py

[Install]
WantedBy=multi-user.target

It is like it is reading a different db when it is called from systemctl…

EDIT: I have removed all the jupyterhub.sqlite files, I have no idea where it is looking for the database…

Solved by (temporarily) setting c.JupyterHub.upgrade_db = True in the config file, but still no idea where the hell it is keeping the database by default…