500 : Internal Server Error, jinja2 related

Hi,
if I run jupyter via jupyter notebook --no-browser and then create a new Python notebook I have " 500 : Internal Server Error" webpage error.

In the shell I have the below error. How to solve it?

Thank you

    HTTPServerRequest(protocol='http', host='localhost:8888', method='GET', uri='/notebooks/Untitled.ipynb?kernel_name=python3', version='HTTP/1.1', remote_ip='127.0.0.1')
    Traceback (most recent call last):
      File "/home/aborruso/.local/lib/python3.9/site-packages/tornado/web.py", line 1704, in _execute
        result = await result
      File "/home/aborruso/.local/lib/python3.9/site-packages/tornado/gen.py", line 775, in run
        yielded = self.gen.send(value)
      File "/home/aborruso/.local/lib/python3.9/site-packages/notebook/notebook/handlers.py", line 95, in get
        self.write(self.render_template('notebook.html',
      File "/home/aborruso/.local/lib/python3.9/site-packages/notebook/base/handlers.py", line 516, in render_template
        return template.render(**ns)
      File "/home/aborruso/.local/lib/python3.9/site-packages/jinja2/environment.py", line 1291, in render
        self.environment.handle_exception()
      File "/home/aborruso/.local/lib/python3.9/site-packages/jinja2/environment.py", line 926, in handle_exception
        raise rewrite_traceback_stack(source=source)
      File "/home/aborruso/.local/lib/python3.9/site-packages/notebook/templates/notebook.html", line 1, in top-level template code
        {% extends "page.html" %}
      File "/home/aborruso/.local/lib/python3.9/site-packages/notebook/templates/page.html", line 154, in top-level template code
        {% block header %}
      File "/home/aborruso/.local/lib/python3.9/site-packages/notebook/templates/notebook.html", line 115, in block 'header'
        {% for exporter in get_frontend_exporters() %}
      File "/home/aborruso/.local/lib/python3.9/site-packages/notebook/notebook/handlers.py", line 23, in get_frontend_exporters
        from nbconvert.exporters.base import get_export_names, get_exporter
      File "/home/aborruso/.local/lib/python3.9/site-packages/nbconvert/__init__.py", line 4, in <module>
        from .exporters import *
      File "/home/aborruso/.local/lib/python3.9/site-packages/nbconvert/exporters/__init__.py", line 3, in <module>
        from .html import HTMLExporter
      File "/home/aborruso/.local/lib/python3.9/site-packages/nbconvert/exporters/html.py", line 14, in <module>
        from jinja2 import contextfilter
    ImportError: cannot import name 'contextfilter' from 'jinja2' (/home/aborruso/.local/lib/python3.9/site-packages/jinja2/__init__.py)
1 Like

I have solved upgrading nbconvert

2 Likes