报错!Jupyter notebook 500 : Internal Server Error

Jupyter notebook 报错 500 : Internal Server Error

在这里插入图片描述

问题背景

tensorflow-gpu环境,为跑特定代码专门开了一个环境,使用conda安装了Jupyter notebook,能够在浏览器打开Jupyter notebook,但是notebook打开ipynb会报错。

问题分析

看到网上很多人日志都不看直接更新包什么的什么不兼容,浪费了自己很多的时间。每个人毛病不同,要想看日志的报错不能直接在conda里面打开Jupyter notebook,从conda中进入指定环境的cmd,如下一样切换到项目目录并使用Jupyter notebook命令打开程序:
报错!Jupyter notebook 500 : Internal Server Error_第1张图片
运行后会弹出浏览器界面,选择ipynb文件打开,这时候会出现500的报错,这时候回到cmd观察Jupyter notebook给出的信息:

HTTPServerRequest(protocol='http', host='localhost:8970', method='GET', uri='/notebooks/Advanced%20Learning%20Algorithms/week1/3.Neural%20network%20model/C2_W1_Lab01_Neurons_and_Layers.ipynb', version='HTTP/1.1', remote_ip='::1')
    Traceback (most recent call last):
      File "D:\Program_Professional\Anaconda3\envs\tensorflow-gpu-v1\lib\site-packages\tornado\web.py", line 1786, in _execute
        result = await result
      File "D:\Program_Professional\Anaconda3\envs\tensorflow-gpu-v1\lib\site-packages\tornado\gen.py", line 786, in run
        yielded = self.gen.send(value)
      File "D:\Program_Professional\Anaconda3\envs\tensorflow-gpu-v1\lib\site-packages\notebook\notebook\handlers.py", line 94, in get
        self.write(self.render_template('notebook.html',
      File "D:\Program_Professional\Anaconda3\envs\tensorflow-gpu-v1\lib\site-packages\notebook\base\handlers.py", line 515, in render_template
        return template.render(**ns)
      File "D:\Program_Professional\Anaconda3\envs\tensorflow-gpu-v1\lib\site-packages\jinja2\environment.py", line 1301, in render
        self.environment.handle_exception()
      File "D:\Program_Professional\Anaconda3\envs\tensorflow-gpu-v1\lib\site-packages\jinja2\environment.py", line 936, in handle_exception
        raise rewrite_traceback_stack(source=source)
      File "D:\Program_Professional\Anaconda3\envs\tensorflow-gpu-v1\lib\site-packages\notebook\templates\notebook.html", line 1, in top-level template code
        {% extends "page.html" %}
      File "D:\Program_Professional\Anaconda3\envs\tensorflow-gpu-v1\lib\site-packages\notebook\templates\page.html", line 187, in top-level template code
        {% block header %}
      File "D:\Program_Professional\Anaconda3\envs\tensorflow-gpu-v1\lib\site-packages\notebook\templates\notebook.html", line 115, in block 'header'
        {% for exporter in get_frontend_exporters() %}
      File "D:\Program_Professional\Anaconda3\envs\tensorflow-gpu-v1\lib\site-packages\notebook\notebook\handlers.py", line 23, in get_frontend_exporters
        from nbconvert.exporters.base import get_export_names, get_exporter
    ModuleNotFoundError: No module named 'nbconvert'
[E 14:49:09.298 NotebookApp] {
      "Host": "localhost:8970",
      "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.7",
      "Referer": "http://localhost:8970/tree/Advanced%20Learning%20Algorithms/week1/3.Neural%20network%20model",
      "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36 Edg/119.0.0.0"
    }

非常明显,报错信息显示ModuleNotFoundError: No module named ‘nbconvert’,我们需要安装nbconvert包。当然,也可以直接在目标环境的cmd中输入 jupyter --version,这也会检测出类似的结果:
报错!Jupyter notebook 500 : Internal Server Error_第2张图片

问题解决

我这边的问题解决十分魔幻,因为我安装nbconvert包后仍然显示nbconvert包没有安装(conda环境显示已经有这个包了,比如下面图片,安装都显示已经安装过了,jupyter --version命令还是检测不到):
报错!Jupyter notebook 500 : Internal Server Error_第3张图片
试了一下安装老版本的nbconvert,问题可以得到解决(pip install nbconvert==6.4.4):
在这里插入图片描述
报错!Jupyter notebook 500 : Internal Server Error_第4张图片
如果此时再使用pip install --upgrade nbconvert命令进行升级,仍然不会报错并能够检测到nbconvert:
报错!Jupyter notebook 500 : Internal Server Error_第5张图片

此时已经能够成功打开ipynb文件啦

你可能感兴趣的:(人工智能,jupyter,ide,python)