mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-18 15:33:02 +00:00
informative error on missing dependencies for singleuser server
- defer jupyter_core import that caused earlier, less informative ImportError - point to `pip install jupyterhub[singleuser]` in the error - use `raise from` so original import error is still reported
This commit is contained in:
@@ -63,9 +63,29 @@ if _as_extension:
|
|||||||
f"Cannot use JUPYTERHUB_SINGLEUSER_EXTENSION={_extension_env} with JUPYTERHUB_SINGLEUSER_APP={_app_env}."
|
f"Cannot use JUPYTERHUB_SINGLEUSER_EXTENSION={_extension_env} with JUPYTERHUB_SINGLEUSER_APP={_app_env}."
|
||||||
" Please pick one or the other."
|
" Please pick one or the other."
|
||||||
)
|
)
|
||||||
|
try:
|
||||||
from .extension import main
|
from .extension import main
|
||||||
|
except ImportError as e:
|
||||||
|
# raise from to preserve original import error
|
||||||
|
raise ImportError(
|
||||||
|
"Failed to import JupyterHub singleuser extension."
|
||||||
|
" Make sure to install dependencies for your single-user server, e.g.\n"
|
||||||
|
" pip install 'jupyterhub[singleuser]'"
|
||||||
|
) from e
|
||||||
else:
|
else:
|
||||||
|
try:
|
||||||
from .app import SingleUserNotebookApp, main
|
from .app import SingleUserNotebookApp, main
|
||||||
|
except ImportError as e:
|
||||||
|
# raise from to preserve original import error
|
||||||
|
if _app_env:
|
||||||
|
_app_env_log = f"JUPYTERHUB_SINGLEUSER_APP={_app_env}"
|
||||||
|
else:
|
||||||
|
_app_env_log = "default single-user server"
|
||||||
|
raise ImportError(
|
||||||
|
f"Failed to import {_app_env_log}."
|
||||||
|
" Make sure to install dependencies for your single-user server, e.g.\n"
|
||||||
|
" pip install 'jupyterhub[singleuser]'"
|
||||||
|
) from e
|
||||||
|
|
||||||
# backward-compatibility
|
# backward-compatibility
|
||||||
if SingleUserNotebookApp is not None:
|
if SingleUserNotebookApp is not None:
|
||||||
|
@@ -22,8 +22,6 @@ rather than keeing these monkey patches around.
|
|||||||
import os
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from jupyter_core import paths
|
|
||||||
|
|
||||||
|
|
||||||
def _is_relative_to(path, prefix):
|
def _is_relative_to(path, prefix):
|
||||||
"""
|
"""
|
||||||
@@ -68,6 +66,10 @@ def _disable_user_config(serverapp):
|
|||||||
2. Search paths for extensions, etc.
|
2. Search paths for extensions, etc.
|
||||||
3. import path
|
3. import path
|
||||||
"""
|
"""
|
||||||
|
# delayed import to avoid triggering early ImportError
|
||||||
|
# with unmet dependencies
|
||||||
|
from jupyter_core import paths
|
||||||
|
|
||||||
original_jupyter_path = paths.jupyter_path()
|
original_jupyter_path = paths.jupyter_path()
|
||||||
jupyter_path_without_home = list(_exclude_home(original_jupyter_path))
|
jupyter_path_without_home = list(_exclude_home(original_jupyter_path))
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user