問題
jupyter notebook打開某一ipynb文件后顯示報(bào)錯(cuò):
500 : Internal Server Error
示意圖如下:
Terminal中的報(bào)錯(cuò):
[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"
}
分析
問題報(bào)錯(cuò)的原因在于nbconvert版本不匹配,導(dǎo)致不兼容,需要進(jìn)行更新。
解決
進(jìn)入conda環(huán)境,輸入以下指令:文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-520045.html
pip install --upgrade --user nbconvert
# --upgrade 更新包
# --user 將Python包安裝到系統(tǒng)目錄
注:一般上述代碼即可解決問題,若上述方法不可行,可嘗試輸入以下指令(可選):文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-520045.html
pip install --upgrade "ipython[all]"
# 更新ipython的全部包
到了這里,關(guān)于報(bào)錯(cuò)解決:jupyter notebook打開顯示500 : Internal Server Error的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!