• 【问题处理小知识】jupyter notebook报错:500 internal server error的几种解决办法整理


    【问题处理小知识】jupyter notebook报错:500 internal server error的解决办法整理

    问题描述

    前一天jupyter notebook可以正常使用,第二天打开时就报错,如下:

    500 internal server error
    
    • 1

    查看后台,会看到如下类似的错误:

    [E 17:53:52.034 NotebookApp] Uncaught exception GET /tree (::1)
        HTTPServerRequest(protocol='http', host='localhost:8888', method='GET', uri='/tree', version='HTTP/1.1', remote_ip='::1', headers={'Accept-Language': 'en-US,en;q=0.8,es;q=0.6', 'Accept-Encoding': 'gzip, deflate, sdch', 'Host': 'localhost:8888', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36', 'Connection': 'keep-alive', 'Upgrade-Insecure-Requests': '1'})
        Traceback (most recent call last):
          File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tornado/web.py", line 1443, in _execute
            result = method(*self.path_args, **self.path_kwargs)
          File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tornado/web.py", line 2800, in wrapper
            return method(self, *args, **kwargs)
          File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/notebook/tree/handlers.py", line 50, in get
            terminals_available=self.settings['terminals_available'],
          File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/notebook/base/handlers.py", line 302, in render_template
            template = self.get_template(name)
          File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/notebook/base/handlers.py", line 298, in get_template
            return self.settings['jinja2_env'].get_template(name)
          File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Jinja2-2.6-py2.7.egg/jinja2/environment.py", line 719, in get_template
            return self._load_template(name, self.make_globals(globals))
          File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Jinja2-2.6-py2.7.egg/jinja2/environment.py", line 693, in _load_template
            template = self.loader.load(self, name, globals)
          File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Jinja2-2.6-py2.7.egg/jinja2/loaders.py", line 127, in load
            code = environment.compile(source, name, filename)
          File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Jinja2-2.6-py2.7.egg/jinja2/environment.py", line 493, in compile
            self.handle_exception(exc_info, source_hint=source)
          File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/notebook/templates/tree.html", line 8, in template
            data-base-url="{{base_url | urlencode}}"
        TemplateAssertionError: no filter named 'urlencode'
    [E 17:53:52.819 NotebookApp] {
          "Accept-Language": "en-US,en;q=0.8,es;q=0.6",
          "Accept-Encoding": "gzip, deflate, sdch",
          "Host": "localhost:8888",
          "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
          "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36",
          "Connection": "keep-alive",
          "Upgrade-Insecure-Requests": "1"
        }
    [E 17:53:52.819 NotebookApp] 500 GET /tree (::1) 874.29ms referer=None
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34

    处理方法总结如下文。

    处理方法汇总

    在处理问题前,建议先升级pip,否则部分包可能会安装出错。pip升级命令如下:

    python.exe -m pip install --upgrade pip
    
    • 1

    下面列举几个方法,总有一个方法能适合你,建议首先尝试第一个方法,如果不行再尝试其他方法。

    方法一

    升级jupyterhub和nbconvert

    pip install --upgrade jupyterhub
    pip install --upgrade --user nbconvert
    
    • 1
    • 2

    方法二

    升级ipython

    pip install --upgrade "ipython[all]"
    
    • 1

    方法三

    安装conda-forge和jupyter_contrib_nbextensions

    conda install -c conda-forge jupyter_contrib_nbextensions
    
    • 1

    其他情况

    如果在利用以上方法解决掉500 internal server error错误后,但是Jupyter notebook连接却无反应,始终卡在connecting to kernel步骤,无法执行cell,那么可能是遇到了jupyter notebook的一个BUG,将jupyter notebook升级到5.7.5即可。升级命令如下:

    pip install jupyter notebook==5.7.5
    
    • 1
  • 相关阅读:
    基于Spring Boot的大学校园防疫与服务系统毕业设计源码111556
    如何搭建一套完整的数据指标体系?_光点科技
    MySQL中的日志(redo log、undo log、binlog)
    anaconda使用系列教程--3)conda命令详解
    反向 Debug 了解一下?揭秘 Java DEBUG 的基本原理
    Javascript Set和Map数据结构
    npm 内网下载 node-sass 出现的问题和解决
    基于Fasthttp实现的Gateway,性能媲美Nginx
    2023-05-24:为什么要使用Redis做缓存?
    认知提升:工作和薪资
  • 原文地址:https://blog.csdn.net/wcl291121957/article/details/136203418