简体   繁体   中英

Jupyter-notebook “500 : Internal Server Error”

I am trying to open jupyter notebook in anaconda but I got a 500: Internal Server Error.

I tried all the solutions from

Jupyter Notebook 500: Internal Server Error

I also tried

pip install update pygments

finally I uninstall and install anaconda but it still doesn't work.

Error message:

[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)

What's probably happening here is that you have created an environment, and installed pygments with pip install pygments . However, I think you forgot to also install jupyter in that env ( conda install jupyter ). In that case, conda falls back to your base env which does have jupyter but probably not pygments. In the same environment you have pygments install you should have jupyter installed.

I would go ahead and do the following:

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

Then,

conda activate YourEnvNameHere

and then type

jupyter notebook

to launch a jupyter notebook on your localhost.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM