AttributeError: module 'notebook.base.handlers' has no attribute 'IPythonHandler' when trying to spawn a session

I’ve been using the Jupyter Hub 1.4 Docker image. I rebuilt and restarted the container a couple of days ago and now cannot spawn a session. I’m using the sudospawner.

The spawning process produces an “AttributeError: module ‘notebook.base.handlers’ has no attribute ‘IPythonHandler’” exception.

Full stack trace:

 Traceback (most recent call last):
   File "/usr/local/lib/python3.9/dist-packages/traitlets/utils/importstring.py", line 32, in import_item
     pak = getattr(module, obj)
 AttributeError: module 'notebook.base.handlers' has no attribute 'IPythonHandler'

 During handling of the above exception, another exception occurred:
 Traceback (most recent call last):
   File "/usr/local/lib/python3.9/dist-packages/jupyterlab/labhubapp.py", line 19, in <module>
     from jupyterhub.singleuser.mixins import make_singleuser_app
   File "/usr/local/lib/python3.9/dist-packages/jupyterhub/singleuser/__init__.py", line 5, in <module>
     from .app import main
   File "/usr/local/lib/python3.9/dist-packages/jupyterhub/singleuser/app.py", line 41, in <module>
     SingleUserNotebookApp = make_singleuser_app(App)
   File "/usr/local/lib/python3.9/dist-packages/jupyterhub/singleuser/mixins.py", line 916, in make_singleuser_app
     BaseHandler = _patch_app_base_handlers(empty_parent_app)
   File "/usr/local/lib/python3.9/dist-packages/jupyterhub/singleuser/mixins.py", line 871, in _patch_app_base_handlers
     base_handlers.append(import_item(base_handler_name))
   File "/usr/local/lib/python3.9/dist-packages/traitlets/utils/importstring.py", line 34, in import_item
     raise ImportError("No module named %s" % obj)
 ImportError: No module named IPythonHandler

Has anyone else experienced this and know how to fix it?
I’ve tried later versions of the Jupyter Hub Docker image without success.

My question is also on StackOverflow.

FYI nbclassic version 4 broke my Jupyter Hub server when the dependency got silently updated after rebuilding my Docker container.

I had to pin it to version 0.3.7.

nbclassic 0.4.2 was just released: it would be interesting to know if it also creates the the breakage you were seeing. If so, as you’ve narrowed this down to nbclassic, posting this as an issue there has a higher likelihood of getting it noticed.