Jupyter notebook: 500 : Internal Server Error

7,725 views
Skip to first unread message

Sylvian Cadars

unread,
May 23, 2022, 8:57:51 AM5/23/22
to aiidausers
Hi,

After updating aiida to version 2.0.1, and migrating my profiles, I cannot use jupyter notebook anymore, whereas the 'verdi shell' seems to work normally and everything appears normal when I type 'verdi status'

I did 'reentry scan' after the update of aiida and all the plugins I use (aiida_vasp, aiida-supercell, etc.), and followed the steps described here: https://aiida.readthedocs.io/projects/aiida-core/en/latest/intro/troubleshooting.html?highlight=troubleshooting#use-in-ipython-jupyter

The browser opens but when I try to open or create a new notebook, or to open the newly-created  <aiida.kernel.name> , I get the following error message:

500 : Internal Server Error

The linux shell shows the folling error:

[I 14:36:22.557 NotebookApp] Serving notebooks from local directory: <LOCAL_DIR>
[I 14:36:22.557 NotebookApp] Jupyter Notebook 6.4.0 is running at:
[I 14:36:22.557 NotebookApp] http://localhost:8888/?token=54808fd50a18c4c7f8dab3eb09abbc9548d47e1ad706bd01
[I 14:36:22.557 NotebookApp]  or http://127.0.0.1:8888/?token=54808fd50a18c4c7f8dab3eb09abbc9548d47e1ad706bd01
[I 14:36:22.557 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 14:36:22.739 NotebookApp]

    To access the notebook, open this file in a browser:
        file:///home/cadarp02/.local/share/jupyter/runtime/nbserver-1522264-open.html
    Or copy and paste one of these URLs:
        http://localhost:8888/?token=54808fd50a18c4c7f8dab3eb09abbc9548d47e1ad706bd01
     or http://127.0.0.1:8888/?token=54808fd50a18c4c7f8dab3eb09abbc9548d47e1ad706bd01
[E 14:36:32.385 NotebookApp] Uncaught exception GET <NOTEBOOK_FILE> (127.0.0.1)
    HTTPServerRequest(protocol='http', host='localhost:8888', method='GET', uri=' <NOTEBOOK_FILE> ', version='HTTP/1.1', remote_ip='127.0.0.1')
    Traceback (most recent call last):
      File "/usr/local/miniconda/envs/aiida/lib/python3.8/site-packages/tornado/web.py", line 1704, in _execute
        result = await result
      File "/usr/local/miniconda/envs/aiida/lib/python3.8/site-packages/tornado/gen.py", line 775, in run
        yielded = self.gen.send(value)
      File "/usr/local/miniconda/envs/aiida/lib/python3.8/site-packages/notebook/notebook/handlers.py", line 95, in get
        self.write(self.render_template('notebook.html',
      File "/usr/local/miniconda/envs/aiida/lib/python3.8/site-packages/notebook/base/handlers.py", line 516, in render_template
        return template.render(**ns)
      File "/usr/local/miniconda/envs/aiida/lib/python3.8/site-packages/jinja2/environment.py", line 1301, in render
        self.environment.handle_exception()
      File "/usr/local/miniconda/envs/aiida/lib/python3.8/site-packages/jinja2/environment.py", line 936, in handle_exception
        raise rewrite_traceback_stack(source=source)
      File "/usr/local/miniconda/envs/aiida/lib/python3.8/site-packages/notebook/templates/notebook.html", line 1, in top-level template code
        {% extends "page.html" %}
      File "/usr/local/miniconda/envs/aiida/lib/python3.8/site-packages/notebook/templates/page.html", line 154, in top-level template code
        {% block header %}
      File "/usr/local/miniconda/envs/aiida/lib/python3.8/site-packages/notebook/templates/notebook.html", line 115, in block 'header'
        {% for exporter in get_frontend_exporters() %}
      File "/usr/local/miniconda/envs/aiida/lib/python3.8/site-packages/notebook/notebook/handlers.py", line 23, in get_frontend_exporters
        from nbconvert.exporters.base import get_export_names, get_exporter
      File "/usr/local/miniconda/envs/aiida/lib/python3.8/site-packages/nbconvert/__init__.py", line 4, in <module>
        from .exporters import *
      File "/usr/local/miniconda/envs/aiida/lib/python3.8/site-packages/nbconvert/exporters/__init__.py", line 3, in <module>
        from .html import HTMLExporter
      File "/usr/local/miniconda/envs/aiida/lib/python3.8/site-packages/nbconvert/exporters/html.py", line 14, in <module>
        from jinja2 import contextfilter
    ImportError: cannot import name 'contextfilter' from 'jinja2' (/usr/local/miniconda/envs/aiida/lib/python3.8/site-packages/jinja2/__init__.py)
[E 14:36:32.389 NotebookApp] {
      "Host": "localhost:8888",
      "Connection": "keep-alive",
      "Sec-Ch-Ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"101\", \"Google Chrome\";v=\"101\"",
      "Sec-Ch-Ua-Mobile": "?0",
      "Sec-Ch-Ua-Platform": "\"Linux\"",
      "Upgrade-Insecure-Requests": "1",
      "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.64 Safari/537.36",
      "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
      "Sec-Fetch-Site": "same-origin",
      "Sec-Fetch-Mode": "navigate",
      "Sec-Fetch-User": "?1",
      "Sec-Fetch-Dest": "document",
      "Referer": "http://localhost:8888/tree",
      "Accept-Encoding": "gzip, deflate, br",
      "Accept-Language": "en-US,en;q=0.9",
      "Cookie": "_xsrf=2|494f2c8b|caf7de9f2c780990d3ff311f096eabbe|1650878910; username-localhost-8889=\"2|1:0|10:1653297195|23:username-localhost-8889|44:NjIyZGUzMjBmZmIzNDVmMGE0NThmYTc1ZDY3NTFjNzU=|9763872e62e9ad84b37b1b99ffa7dc4b3504c574b3458a4156932fa76067a0bd\"; username-localhost-8888=\"2|1:0|10:1653309384|23:username-localhost-8888|44:NzVkNzk4YjczMTczNGM5MzgxZmE3NmYwNDg2ZGI1MWE=|4bb1230ac88fa0647e438c04c1664373a9d6cefdb813c326601d9d320bbbf938\""
    }
[E 14:36:32.389 NotebookApp] 500 GET  <NOTEBOOK_FILE> (127.0.0.1) 33.020000ms referer=http://localhost:8888/tree

Can you please help me figure out what is wrong ?
Thank you veru much.
Best regards.
Sylvian.

Sebastiaan Huber

unread,
May 23, 2022, 9:30:14 AM5/23/22
to aiida...@googlegroups.com
Hi Sylvian,

It seems you have installed a more recent version of Jinja2 and that is breaking nbconvert.
You can either try to update nbconvert or downgrade jinja2.
The code that is breaking was removed in jinja2==3.1.0, so maybe first try

    pip install jinja2==3.0.3

then try the notebook again.
If that doesn't work, try to update `nbconvert`.
Note that there might be other packages in your environment that depend on jinja2 that could be broken.

HTH,

Sebastiaan
--
AiiDA is supported by the NCCR MARVEL (http://nccr-marvel.ch/), funded by the Swiss National Science Foundation, and by the European H2020 MaX Centre of Excellence (http://www.max-centre.eu/).
 
Before posting your first question, please see the posting guidelines at http://www.aiida.net/?page_id=356 .
---
You received this message because you are subscribed to the Google Groups "aiidausers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to aiidausers+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/aiidausers/b4d996b0-7fbb-4111-ad3a-050072ea23ffn%40googlegroups.com.

Sylvian Cadars

unread,
May 25, 2022, 8:50:31 AM5/25/22
to aiidausers
Dear Sebastiaan,

Thank you for your response. The first solution (i.e. downgrading jinja2 to version 3.0.3) seem to have worked fine.

Is it someting I should care about nex time I update aiida ?

Thank you very much.
Best regards.
Sylvian.

Sebastiaan Huber

unread,
May 30, 2022, 3:26:07 AM5/30/22
to aiida...@googlegroups.com
Dear Sylvian,

We try our best to keep dependencies and requirements up to date, but unfortunately there is nothing we can do to 100% prevent any package downstream breaking things.
It might not even be our direct dependency, but a dependency of a dependency... (as was the case here).
There is no automatic solution for this unfortunately.

Regards,

Sebastiaan
Reply all
Reply to author
Forward
0 new messages