# 500 : Internal Server Error, jinja2 related

**URL:** <https://discourse.jupyter.org/t/500-internal-server-error-jinja2-related/13878>\
**Category:** JupyterHub\
**Tags:** help-wanted\
**Created:** [April 14, 2022, 3:44pm UTC](https://discourse.jupyter.org/t/500-internal-server-error-jinja2-related/13878 "2022-04-14T15:44:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![aborruso](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/aborruso/32/6954_2.png) [@aborruso](https://discourse.jupyter.org/u/aborruso)\
**Post date:** [April 14, 2022, 3:44pm UTC](https://discourse.jupyter.org/t/500-internal-server-error-jinja2-related/13878/1 "2022-04-14T15:44:44Z")

</div>

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

```auto
    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)

```

---

<div class="post-metadata">

**Author:** ![aborruso](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/aborruso/32/6954_2.png) [@aborruso](https://discourse.jupyter.org/u/aborruso)\
**Post date:** [April 14, 2022, 3:49pm UTC](https://discourse.jupyter.org/t/500-internal-server-error-jinja2-related/13878/2 "2022-04-14T15:49:18Z")

</div>

I have solved upgrading nbconvert

---

<div class="post-metadata">

**Author:** ![nikhilvishwanath](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/nikhilvishwanath/32/9023_2.png) [@nikhilvishwanath](https://discourse.jupyter.org/u/nikhilvishwanath)\
**Post date:** [February 2, 2023, 8:30am UTC](https://discourse.jupyter.org/t/500-internal-server-error-jinja2-related/13878/3 "2023-02-02T08:30:02Z")

</div>

Upgrading nbconvert solved it

---

<div class="post-metadata">

**Author:** ![shad3000](https://avatars.discourse-cdn.com/v4/letter/s/d07c76/32.png) [@shad3000](https://discourse.jupyter.org/u/shad3000)\
**Post date:** [March 29, 2024, 1:06pm UTC](https://discourse.jupyter.org/t/500-internal-server-error-jinja2-related/13878/4 "2024-03-29T13:06:35Z")

</div>

Hello  
Nothing is working on my end: I created a new conda environment, upgraded nbconvert, upgraded jinja2, uninstalled and re-installed jupyter-notebook.  
I still get the same error: ImportError: cannot import name ‘contextfilter’ from ‘jinja2’

Python 3.9.19  
jupyter-notebook 6.0.3  
jinja2 3.1.3  
nbconvert 7.16.3

I’m grateful if someone has an idea as I cannot open any jupyter-notebooks now

---

<div class="post-metadata">

**Author:** ![fomightez](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/fomightez/32/495_2.png) [@fomightez](https://discourse.jupyter.org/u/fomightez)\
**Post date:** [March 29, 2024, 8:33pm UTC](https://discourse.jupyter.org/t/500-internal-server-error-jinja2-related/13878/5 "2024-03-29T20:33:07Z")

</div>

You seem to be using really old Python and Jupyter Notbeook versions with super modern jinga and nbconvert. This does not equate with what you said of making a new conda environment and upgrading things. If you are sure your environments are stored good, you should uninstall and clear out all Anaconda/conda it seems.
