Login of os user to jupyterhub fails with SudoSpawner


I want to run jupyterhub on my local linux server to allow users of that server to use jupyter.
My server distro is opensuse leap 15.3 and I dont want to use docker for this, so I decided to add a service user with conda environment including jupyterhub and SudoSpawner, configure sudo and start the hub

I installed it following the wiki as close as possible. The hub starts, but if I log in, I get " 500 : Internal Server Error", probably caused by jupyterhub-singleuser failing to import main. Unfortunately that error message is too generic for me to understand what is going on. Maybe you can help?

Sudo works:

job4:~ > sudo -u jupyterhub sudo -n -u $USER /home/jupyterhub/miniconda3/bin/sudospawner --help
Usage: /home/jupyterhub/miniconda3/bin/sudospawner [OPTIONS]

This is the full output of the hub console

(base) job4:~ > jupyterhub --JupyterHub.spawner_class=sudospawner.SudoSpawner
[I 2022-04-01 14:42:41.379 JupyterHub app:2769] Running JupyterHub version 2.2.2
[I 2022-04-01 14:42:41.379 JupyterHub app:2799] Using Authenticator: jupyterhub.auth.PAMAuthenticator-2.2.2
[I 2022-04-01 14:42:41.379 JupyterHub app:2799] Using Spawner: sudospawner.spawner.SudoSpawner
[I 2022-04-01 14:42:41.379 JupyterHub app:2799] Using Proxy: jupyterhub.proxy.ConfigurableHTTPProxy-2.2.2
[I 2022-04-01 14:42:41.382 JupyterHub app:1606] Loading cookie_secret from /home/jupyterhub/jupyterhub_cookie_secret
[I 2022-04-01 14:42:41.432 JupyterHub proxy:496] Generating new CONFIGPROXY_AUTH_TOKEN
[I 2022-04-01 14:42:41.440 JupyterHub app:1924] Not using allowed_users. Any authenticated user will be allowed.
[I 2022-04-01 14:42:41.460 JupyterHub app:2838] Initialized 0 spawners in 0.002 seconds
[W 2022-04-01 14:42:41.462 JupyterHub proxy:687] Running JupyterHub without SSL.  I hope there is SSL termination happening somewhere else...
[I 2022-04-01 14:42:41.462 JupyterHub proxy:691] Starting proxy @ http://:7000
14:42:41.642 [ConfigProxy] info: Proxying http://*:7000 to (no default)
14:42:41.644 [ConfigProxy] info: Proxy API at
[I 2022-04-01 14:42:42.011 JupyterHub app:3087] Hub API listening on
14:42:42.011 [ConfigProxy] info: 200 GET /api/routes 
14:42:42.012 [ConfigProxy] info: 200 GET /api/routes 
[I 2022-04-01 14:42:42.012 JupyterHub proxy:431] Adding route for Hub: / =>
14:42:42.014 [ConfigProxy] info: Adding route / ->
14:42:42.014 [ConfigProxy] info: Route added / ->
14:42:42.014 [ConfigProxy] info: 201 POST /api/routes/ 
[I 2022-04-01 14:42:42.015 JupyterHub app:3154] JupyterHub is now running at http://:7000

[I 2022-04-01 14:42:52.505 JupyterHub log:189] 200 GET /hub/home (joachim@::1) 39.27ms
[I 2022-04-01 14:43:05.652 JupyterHub roles:482] Adding role server to token: <APIToken('b1cc...', user='joachim', client_id='jupyterhub')>
[I 2022-04-01 14:43:05.659 JupyterHub provider:607] Creating oauth client jupyterhub-user-joachim
[I 220401 14:43:05 mediator:89] Spawning /home/jupyterhub/miniconda3/bin/jupyterhub-singleuser
Traceback (most recent call last):
  File "/home/jupyterhub/miniconda3/bin/jupyterhub-singleuser", line 7, in <module>
    from jupyterhub.singleuser import main
  File "/home/jupyterhub/miniconda3/lib/python3.9/site-packages/jupyterhub/singleuser/__init__.py", line 5, in <module>
    from .app import main
  File "/home/jupyterhub/miniconda3/lib/python3.9/site-packages/jupyterhub/singleuser/app.py", line 38, in <module>
    raise _import_error
TypeError: exceptions must derive from BaseException
[E 220401 14:43:06 mediator:43] mediator result: {'ok': False, 'error': 'Exited with status: 1'}
[E 2022-04-01 14:43:06.555 JupyterHub user:815] Unhandled error starting joachim's server: 'pid'
[E 2022-04-01 14:43:06.581 JupyterHub pages:317] Error starting server joachim: 'pid'
    Traceback (most recent call last):
    None: None
[W 2022-04-01 14:43:06.581 JupyterHub web:1787] 500 GET /hub/spawn/joachim (::1): Unhandled error starting server joachim
[E 2022-04-01 14:43:06.602 JupyterHub log:181] {
      "X-Forwarded-Host": "localhost:7000",
      "X-Forwarded-Proto": "http",
      "X-Forwarded-Port": "7000",
      "X-Forwarded-For": "::1",
      "Cookie": "jupyterhub-hub-login=[secret]; jupyterhub-session-id=[secret]",
      "Accept-Language": "de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7",
      "Accept-Encoding": "gzip, deflate, br",
      "Referer": "http://localhost:7000/hub/home",
      "Sec-Fetch-Dest": "document",
      "Sec-Fetch-User": "?1",
      "Sec-Fetch-Mode": "navigate",
      "Sec-Fetch-Site": "same-origin",
      "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
      "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.74 Safari/537.36",
      "Upgrade-Insecure-Requests": "1",
      "Sec-Ch-Ua-Platform": "\"Linux\"",
      "Sec-Ch-Ua-Mobile": "?0",
      "Sec-Ch-Ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"99\"",
      "Connection": "close",
      "Host": "localhost:7000"
[E 2022-04-01 14:43:06.602 JupyterHub log:189] 500 GET /hub/spawn/joachim (joachim@::1) 962.72ms


I looked into /home/jupyterhub/miniconda3/lib/python3.9/site-packages/jupyterhub/singleuser/app.py and discovered it wants to import jupyterlab … and that was not a dependency of jupyterhub as I blindly assumed, so not installed. I installed it and all is well for now :slight_smile:

on to ssl and systemd…