【问题标题】:Jupyter-notebook "500 : Internal Server Error"Jupyter-notebook“500:内部服务器错误”
【发布时间】:2020-05-12 09:56:57
【问题描述】:

我正在尝试在 anaconda 中打开 jupyter notebook,但出现 500:内部服务器错误。

我尝试了

的所有解决方案

Jupyter Notebook 500 : Internal Server Error

我也试过

pip install update pygments

最后我卸载并安装了anaconda,但还是不行。

错误信息:

[E 19:45:02.700 NotebookApp] Uncaught exception GET /notebooks/Untitled.ipynb (::1)
HTTPServerRequest(protocol='http', host='localhost:8888', method='GET', uri='/notebooks/Untitled.ipynb', version='HTTP/1.1', remote_ip='::1')
Traceback (most recent call last):
  File "C:\Users\m\anaconda3\envs\my_env\lib\site-packages\tornado\web.py", line 1592, in _execute
    result = yield result
  File "C:\Users\m\anaconda3\envs\my_env\lib\site-packages\tornado\gen.py", line 1133, in run
    value = future.result()
  File "C:\Users\m\anaconda3\envs\my_env\lib\site-packages\tornado\gen.py", line 1147, in run
    yielded = self.gen.send(value)
  File "C:\Users\m\anaconda3\envs\my_env\lib\site-packages\notebook\notebook\handlers.py", line 101, in get
    get_frontend_exporters=get_frontend_exporters
  File "C:\Users\m\anaconda3\envs\my_env\lib\site-packages\notebook\base\handlers.py", line 507, in render_template
    return template.render(**ns)
  File "C:\Users\m\anaconda3\envs\my_env\lib\site-packages\jinja2\environment.py", line 1090, in render
    self.environment.handle_exception()
  File "C:\Users\m\anaconda3\envs\my_env\lib\site-packages\jinja2\environment.py", line 832, in handle_exception
    reraise(*rewrite_traceback_stack(source=source))
  File "C:\Users\m\anaconda3\envs\my_env\lib\site-packages\jinja2\_compat.py", line 28, in reraise
    raise value.with_traceback(tb)
  File "C:\Users\m\anaconda3\envs\my_env\lib\site-packages\notebook\templates\notebook.html", line 1, in top-level template code
    {% extends "page.html" %}
  File "C:\Users\m\anaconda3\envs\my_env\lib\site-packages\notebook\templates\page.html", line 154, in top-level template code
    {% block header %}
  File "C:\Users\m\anaconda3\envs\my_env\lib\site-packages\notebook\templates\notebook.html", line 114, in block "header"
    {% for exporter in get_frontend_exporters() %}
  File "C:\Users\m\anaconda3\envs\my_env\lib\site-packages\notebook\notebook\handlers.py", line 23, in get_frontend_exporters
    from nbconvert.exporters.base import get_export_names, get_exporter
  File "C:\Users\m\anaconda3\envs\my_env\lib\site-packages\nbconvert\__init__.py", line 4, in <module>
    from .exporters import *
  File "C:\Users\m\anaconda3\envs\my_env\lib\site-packages\nbconvert\exporters\__init__.py", line 3, in <module>
    from .html import HTMLExporter
  File "C:\Users\m\anaconda3\envs\my_env\lib\site-packages\nbconvert\exporters\html.py", line 15, in <module>
    from nbconvert.filters.markdown_mistune import IPythonRenderer, MarkdownWithMath
  File "C:\Users\m\anaconda3\envs\my_env\lib\site-packages\nbconvert\filters\markdown_mistune.py", line 24, in <module>
    from pygments.lexers import get_lexer_by_name
ImportError: cannot import name 'get_lexer_by_name' from 'pygments.lexers' (unknown location)

【问题讨论】:

  • 你试过将它安装在同一个 conda env 中吗?
  • 你是说jupyter notebook吗?我已经将它安装在同一个环境中。

标签: python jupyter-notebook anaconda


【解决方案1】:

这里可能发生的是您已经创建了一个环境,并使用pip install pygments 安装了 pygments。但是,我认为您忘记在该环境中安装 jupyter (conda install jupyter)。在这种情况下,conda 会退回到你的base env,它确实有 jupyter 但可能没有 pygments。在 same 环境中,您安装了 pygments,您应该安装了 jupyter。

我会继续做以下事情:

conda create --name YourEnvNameHere python=3.6 jupyter pygments ... any_other_package_you_need

那么,

conda activate YourEnvNameHere

然后输入

jupyter notebook

在你的本地主机上启动一个 jupyter notebook。

【讨论】:

  • 我试过了,对我没用。在错误发生之前我从未安装过 pygment,它是在我设置环境时预先安装的
猜你喜欢
  • 2016-08-19
  • 1970-01-01
  • 2022-06-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多