Upgrade to jupyter notebook 7.0.0 produces 500: Internal Server Error for jupyter nbclassic

796 views Asked by At

After a conda update --all of my env, comprising also an upgrade to jupyter notebook 7.0.0 the jupyter nbclassic does not allow notebooks to be created or loaded anymore.

Whenever I try, I get a 500: Internal Server Error, moreover the console displays the following [E ...] msgs.

Any suggestions on what the problem is and how to fix it are most welcome.

[I 2023-07-24 15:19:00.816 ServerApp] Creating new notebook in 
[E 2023-07-24 15:19:01.029 ServerApp] Uncaught exception GET /nbclassic/notebooks/Untitled.ipynb?kernel_name=python3 (127.0.0.1)
    HTTPServerRequest(protocol='http', host='localhost:8888', method='GET', uri='/nbclassic/notebooks/Untitled.ipynb?kernel_name=python3', version='HTTP/1.1', remote_ip='127.0.0.1')
    Traceback (most recent call last):
      File "/home/UserX/.anaconda3/envs/py/lib/python3.9/site-packages/tornado/web.py", line 1786, in _execute
        result = await result
      File "/home/UserX/.anaconda3/envs/py/lib/python3.9/site-packages/tornado/gen.py", line 786, in run
        yielded = self.gen.send(value)
      File "/home/UserX/.anaconda3/envs/py/lib/python3.9/site-packages/nbclassic/notebook/handlers.py", line 101, in get
        self.write(self.render_template('notebook.html',
      File "/home/UserX/.anaconda3/envs/py/lib/python3.9/site-packages/jupyter_server/base/handlers.py", line 639, in render_template
        return template.render(**ns)
      File "/home/UserX/.anaconda3/envs/py/lib/python3.9/site-packages/jinja2/environment.py", line 1301, in render
        self.environment.handle_exception()
      File "/home/UserX/.anaconda3/envs/py/lib/python3.9/site-packages/jinja2/environment.py", line 936, in handle_exception
        raise rewrite_traceback_stack(source=source)
      File "/home/UserX/.anaconda3/envs/py/lib/python3.9/site-packages/nbclassic/templates/notebook.html", line 1, in top-level template code
        {% extends "page.html" %}
      File "/home/UserX/.anaconda3/envs/py/lib/python3.9/site-packages/nbclassic/templates/page.html", line 190, in top-level template code
        {% block header %}
      File "/home/UserX/.anaconda3/envs/py/lib/python3.9/site-packages/nbclassic/templates/notebook.html", line 115, in block 'header'
        {% for exporter in get_frontend_exporters() %}
      File "/home/UserX/.anaconda3/envs/py/lib/python3.9/site-packages/nbclassic/notebook/handlers.py", line 46, in get_frontend_exporters
        for name in get_export_names():
      File "/home/UserX/.anaconda3/envs/py/lib/python3.9/site-packages/nbconvert/exporters/base.py", line 150, in get_export_names
        e = get_exporter(exporter_name)(config=config)
      File "/home/UserX/.anaconda3/envs/py/lib/python3.9/site-packages/nbconvert/exporters/base.py", line 109, in get_exporter
        exporter = [e for e in exporters if e.name == name or e.name == name.lower()][0].load()
      File "/home/UserX/.anaconda3/envs/py/lib/python3.9/site-packages/importlib_metadata/__init__.py", line 209, in load
        module = import_module(match.group('module'))
      File "/home/UserX/.anaconda3/envs/py/lib/python3.9/importlib/__init__.py", line 127, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
      File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
      File "<frozen importlib._bootstrap>", line 972, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
      File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
      File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
      File "<frozen importlib._bootstrap>", line 972, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
      File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
      File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
      File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
      File "<frozen importlib._bootstrap_external>", line 850, in exec_module
      File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
      File "/home/UserX/.anaconda3/envs/py/lib/python3.9/site-packages/jupyter_contrib_nbextensions/__init__.py", line 5, in <module>
        import jupyter_nbextensions_configurator
      File "/home/UserX/.anaconda3/envs/py/lib/python3.9/site-packages/jupyter_nbextensions_configurator/__init__.py", line 17, in <module>
        from notebook import version_info as nb_version_info
    ImportError: cannot import name 'version_info' from 'notebook' (/home/UserX/.anaconda3/envs/py/lib/python3.9/site-packages/notebook/__init__.py)
[E 2023-07-24 15:19:01.034 NotebookApp] {
      "Host": "localhost:8888",
      "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8",
      "Referer": "http://localhost:8888/nbclassic/tree",
      "User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/115.0"
    }
[E 2023-07-24 15:19:01.034 NotebookApp] 500 GET /nbclassic/notebooks/Untitled.ipynb?kernel_name=python3 ([email protected]) 152.26ms referer=http://localhost:8888/nbclassic/tree
2

There are 2 answers

1
Mark On

There seem to be a myriad of causes for the 500: Internal Server Error for jupyter which are described on the internet. (In particular there are many suggestions to up/downgrade nbconvert). None of those I found did apply to my case.

My case "somehow(?)" seems to be related to the the very recent migration issues with notebook extensions in going from jupyter < 7 to >=7, as this section of the err msgs, mentioned in the OP seem to suggest:

File "/home/UserX/.anaconda3/envs/py/lib/python3.9/site-packages/jupyter_nbextensions_configurator/__init__.py", line 17, in <module>
        from notebook import version_info as nb_version_info
ImportError: cannot import name 'version_info' from 'notebook' (/home/UserX/.anaconda3/envs/py/lib/python3.9/site-packages/notebook/__init__.py)

Anyway, with heavy heart, I did a conda remove jupyter_nbextensions_configurator, deleting also its dependencies, including my beloved nbextensions (SIGH), and this solved the issue posted here.

1
Rire On

Same problem while conda install jupyter_contrib_nbextensions with notebook v7.0.0

Also "jupyter-nbextensions not found" while conda install nb_conda

Tried python=3.9 and =3.10 env, not solve.