报错解决:jupyter notebook打开显示500 : Internal Server Error

报错解决:jupyter notebook打开显示500 : Internal Server Error

问题

jupyter notebook打开某一ipynb文件后显示报错:

500 : Internal Server Error

示意图如下:
请添加图片描述

Terminal中的报错:

[E 15:38:38.448 NotebookApp] Uncaught exception GET /notebooks/code/Untitled1.ipynb?kernel_name=conda-env-python-py (127.0.0.1)
    HTTPServerRequest(protocol='http', host='localhost:8888', method='GET', uri='/notebooks/code/Untitled1.ipynb?kernel_name=conda-env-python-py', version='HTTP/1.1', remote_ip='127.0.0.1')
    Traceback (most recent call last):
      File "/home/marcos/anaconda3/envs/python/lib/python3.8/site-packages/tornado/web.py", line 1713, in _execute
        result = await result
      File "/home/marcos/anaconda3/envs/python/lib/python3.8/site-packages/tornado/gen.py", line 782, in run
        yielded = self.gen.send(value)
      File "/home/marcos/anaconda3/envs/python/lib/python3.8/site-packages/notebook/notebook/handlers.py", line 94, in get
        self.write(self.render_template('notebook.html',
      File "/home/marcos/anaconda3/envs/python/lib/python3.8/site-packages/notebook/base/handlers.py", line 511, in render_template
        return template.render(**ns)
      File "/home/marcos/anaconda3/envs/python/lib/python3.8/site-packages/jinja2/environment.py", line 1301, in render
        self.environment.handle_exception()
      File "/home/marcos/anaconda3/envs/python/lib/python3.8/site-packages/jinja2/environment.py", line 936, in handle_exception
        raise rewrite_traceback_stack(source=source)
      File "/home/marcos/anaconda3/envs/python/lib/python3.8/site-packages/notebook/templates/notebook.html", line 1, in top-level template code
        {% extends "page.html" %}
      File "/home/marcos/anaconda3/envs/python/lib/python3.8/site-packages/notebook/templates/page.html", line 166, in top-level template code
        {% block header %}
      File "/home/marcos/anaconda3/envs/python/lib/python3.8/site-packages/notebook/templates/notebook.html", line 115, in block 'header'
        {% for exporter in get_frontend_exporters() %}
      File "/home/marcos/anaconda3/envs/python/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 "/home/marcos/anaconda3/envs/python/lib/python3.8/site-packages/nbconvert/__init__.py", line 3, in <module>
        from . import filters, postprocessors, preprocessors, writers
      File "/home/marcos/anaconda3/envs/python/lib/python3.8/site-packages/nbconvert/filters/__init__.py", line 8, in <module>
        from .markdown import *
      File "/home/marcos/anaconda3/envs/python/lib/python3.8/site-packages/nbconvert/filters/markdown.py", line 13, in <module>
        from .markdown_mistune import markdown2html_mistune
      File "/home/marcos/anaconda3/envs/python/lib/python3.8/site-packages/nbconvert/filters/markdown_mistune.py", line 37, in <module>
        class MathBlockGrammar(mistune.BlockGrammar):
    AttributeError: module 'mistune' has no attribute 'BlockGrammar'
[E 15:38:38.452 NotebookApp] {
      "Host": "localhost:8888",
      "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",
      "Referer": "http://localhost:8888/tree/code",
      "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36"
    }

分析

问题报错的原因在于nbconvert版本不匹配,导致不兼容,需要进行更新。

解决

进入conda环境,输入以下指令:

pip install --upgrade --user nbconvert
# --upgrade 更新包
# --user 将Python包安装到系统目录

注:一般上述代码即可解决问题,若上述方法不可行,可尝试输入以下指令(可选):

pip install --upgrade "ipython[all]"
# 更新ipython的全部包
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

AI Player

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值