解决jupyter notebook 新建或打开.ipynb 报500 : Internal Server Error(涉及jinja2兼容性问题)
报错:
[E 10:09:52.362 NotebookApp] 500 GET /notebooks/Untitled16.ipynb?kernel_name=pyt hon3 (::1) 93.000000ms referer=http://localhost:8888/tree
......
重点是:
from .exporters import * File "C:\ProgramData\Anaconda3\lib\site-packages\nbconvert\exporters\__ini t__.py", line 3, in <module> from .html import HTMLExporter File "C:\ProgramData\Anaconda3\lib\site-packages\nbconvert\exporters\html. py", line 14, in <module> from jinja2 import contextfilter ImportError: cannot import name 'contextfilter' from 'jinja2' (C:\ProgramDat a\Anaconda3\lib\site-packages\jinja2\__init__.py) [E 10:17:44.277 NotebookApp] { "Host": "localhost:8888",
找到问题是from jinja2 import contextfilter
查找资料是3.0.3 版本以后,jinja2移除了contextfilter方法
所以只能卸载jinja2的较新版本,降级到3.0.3 版本了。
pip uninstall jinja2
pip install jinja2==3.0.3