joy_w 发表于 2022-5-4 14:12:04

在jupyter打开文件报错 500 : Internal Server Error

请问有没有人知道这是为什么?
完整内容如下:

<(base) C:\Users\chxyw>jupyter notebook
The port 8888 is already in use, trying another port.
Serving notebooks from local directory: C:\Users\chxyw
Jupyter Notebook 6.4.11 is running at:
http://localhost:8889/?token=ad1bdb020f844755dad25ee7d242f559c5dee48fc6be6f7e
or http://127.0.0.1:8889/?token=ad1bdb020f844755dad25ee7d242f559c5dee48fc6be6f7e
Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).


    To access the notebook, open this file in a browser:
      file:///C:/Users/chxyw/AppData/Roaming/jupyter/runtime/nbserver-17972-open.html
    Or copy and paste one of these URLs:
      http://localhost:8889/?token=ad1bdb020f844755dad25ee7d242f559c5dee48fc6be6f7e
   or http://127.0.0.1:8889/?token=ad1bdb020f844755dad25ee7d242f559c5dee48fc6be6f7e
Uncaught exception GET /notebooks/ML/regress_1.ipynb (::1)
    HTTPServerRequest(protocol='http', host='localhost:8889', method='GET', uri='/notebooks/ML/regress_1.ipynb', version='HTTP/1.1', remote_ip='::1')
    Traceback (most recent call last):
      File "C:\Users\chxyw\AppData\Roaming\Python\Python37\site-packages\tornado\web.py", line 1704, in _execute
      result = await result
      File "C:\Users\chxyw\AppData\Roaming\Python\Python37\site-packages\tornado\gen.py", line 775, in run
      yielded = self.gen.send(value)
      File "C:\Users\chxyw\AppData\Roaming\Python\Python37\site-packages\notebook\notebook\handlers.py", line 100, in get
      get_frontend_exporters=get_frontend_exporters
      File "C:\Users\chxyw\AppData\Roaming\Python\Python37\site-packages\notebook\base\handlers.py", line 511, in render_template
      return template.render(**ns)
      File "C:\Users\chxyw\AppData\Roaming\Python\Python37\site-packages\jinja2\environment.py", line 1301, in render
      self.environment.handle_exception()
      File "C:\Users\chxyw\AppData\Roaming\Python\Python37\site-packages\jinja2\environment.py", line 936, in handle_exception
      raise rewrite_traceback_stack(source=source)
      File "C:\Users\chxyw\AppData\Roaming\Python\Python37\site-packages\notebook\templates\notebook.html", line 1, in top-level template code
      {% extends "page.html" %}
      File "C:\Users\chxyw\AppData\Roaming\Python\Python37\site-packages\notebook\templates\page.html", line 154, in top-level template code
      {% block header %}
      File "C:\Users\chxyw\AppData\Roaming\Python\Python37\site-packages\notebook\templates\notebook.html", line 115, in block 'header'
      {% for exporter in get_frontend_exporters() %}
      File "C:\Users\chxyw\AppData\Roaming\Python\Python37\site-packages\notebook\notebook\handlers.py", line 40, in get_frontend_exporters
      for name in get_export_names():
      File "C:\Users\chxyw\AppData\Roaming\Python\Python37\site-packages\nbconvert\exporters\base.py", line 149, in get_export_names
      e = get_exporter(exporter_name)(config=config)
      File "C:\Users\chxyw\AppData\Roaming\Python\Python37\site-packages\nbconvert\exporters\base.py", line 100, in get_exporter
      exporter = entrypoints.get_single("nbconvert.exporters", name).load()
      File "C:\Users\chxyw\AppData\Roaming\Python\Python37\site-packages\entrypoints.py", line 79, in load
      mod = import_module(self.module_name)
      File "C:\Users\chxyw\.conda\envs\py3.7\lib\importlib\__init__.py", line 127, in import_module
      return _bootstrap._gcd_import(name, package, level)
      File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
      File "<frozen importlib._bootstrap>", line 983, in _find_and_load
      File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
      File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
      File "<frozen importlib._bootstrap>", line 983, in _find_and_load
      File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
      File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
      File "<frozen importlib._bootstrap>", line 983, in _find_and_load
      File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
      File "<frozen importlib._bootstrap_external>", line 728, in exec_module
      File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
      File "C:\Users\chxyw\AppData\Roaming\Python\Python37\site-packages\jupyter_contrib_nbextensions\__init__.py", line 5, in <module>
      import jupyter_nbextensions_configurator
      File "C:\Users\chxyw\AppData\Roaming\Python\Python37\site-packages\jupyter_nbextensions_configurator\__init__.py", line 16, in <module>
      import yaml
    ModuleNotFoundError: No module named 'yaml'
{
      "Host": "localhost:8889",
      "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
      "Referer": "http://localhost:8889/tree/ML",
      "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/99.0.4844.51 Safari/537.36 Edg/99.0.1150.39"
    }
500 GET /notebooks/ML/regress_1.ipynb (::1) 1204.390000ms referer=http://localhost:8889/tree/ML>

isdkz 发表于 2022-5-4 14:25:32

本帖最后由 isdkz 于 2022-5-4 14:32 编辑

你的报错信息里有一句

ModuleNotFoundError: No module named 'yaml'

应该是缺少了 pyyaml 这个库,执行一下这条命令看看:

pip install pyyaml -i https://mirrors.aliyun.com/pypi/simple
页: [1]
查看完整版本: 在jupyter打开文件报错 500 : Internal Server Error