由于“ tornado.web”没有属性“ asynchronous”,如何在Jupyter Notebook上修复“ 500:内部服务器错误”?

时间:2019-03-05 23:26:47

标签: python jupyter-notebook

Jupiter笔记本无法打开笔记本,而是显示“ 500:内部服务器错误”。我所做的就是激活所需的环境并启动Jupyter。请在下面找到我的操作以及终端上的错误消息:

[E 18:22:16.169 NotebookApp] Uncaught exception GET /notebooks/backtracking-sample-1.ipynb (::1)
    HTTPServerRequest(protocol='http', host='localhost:8888', method='GET', uri='/notebooks/backtracking-sample-1.ipynb', version='HTTP/1.1', remote_ip='::1')
    Traceback (most recent call last):
      File "/Users/davidlindo-atichati/miniconda3/envs/py3_parcels/lib/python3.7/site-packages/tornado/web.py", line 1697, in _execute
        result = method(*self.path_args, **self.path_kwargs)
      File "/Users/davidlindo-atichati/miniconda3/envs/py3_parcels/lib/python3.7/site-packages/tornado/web.py", line 3174, in wrapper
        return method(self, *args, **kwargs)
      File "/Users/davidlindo-atichati/miniconda3/envs/py3_parcels/lib/python3.7/site-packages/notebook/notebook/handlers.py", line 59, in get
        get_custom_frontend_exporters=get_custom_frontend_exporters
      File "/Users/davidlindo-atichati/miniconda3/envs/py3_parcels/lib/python3.7/site-packages/notebook/base/handlers.py", line 467, in render_template
        return template.render(**ns)
      File "/Users/davidlindo-atichati/miniconda3/envs/py3_parcels/lib/python3.7/site-packages/jinja2/asyncsupport.py", line 76, in render
        return original_render(self, *args, **kwargs)
      File "/Users/davidlindo-atichati/miniconda3/envs/py3_parcels/lib/python3.7/site-packages/jinja2/environment.py", line 1008, in render
        return self.environment.handle_exception(exc_info, True)
      File "/Users/davidlindo-atichati/miniconda3/envs/py3_parcels/lib/python3.7/site-packages/jinja2/environment.py", line 780, in handle_exception
        reraise(exc_type, exc_value, tb)
      File "/Users/davidlindo-atichati/miniconda3/envs/py3_parcels/lib/python3.7/site-packages/jinja2/_compat.py", line 37, in reraise
        raise value.with_traceback(tb)
      File "/Users/davidlindo-atichati/miniconda3/envs/py3_parcels/lib/python3.7/site-packages/notebook/templates/notebook.html", line 1, in top-level template code
        {% extends "page.html" %}
      File "/Users/davidlindo-atichati/miniconda3/envs/py3_parcels/lib/python3.7/site-packages/notebook/templates/page.html", line 154, in top-level template code
        {% block header %}
      File "/Users/davidlindo-atichati/miniconda3/envs/py3_parcels/lib/python3.7/site-packages/notebook/templates/notebook.html", line 120, in block "header"
        {% for exporter in get_custom_frontend_exporters() %}
      File "/Users/davidlindo-atichati/miniconda3/envs/py3_parcels/lib/python3.7/site-packages/notebook/notebook/handlers.py", line 19, in get_custom_frontend_exporters
        from nbconvert.exporters.base import get_export_names, get_exporter
      File "/Users/davidlindo-atichati/miniconda3/envs/py3_parcels/lib/python3.7/site-packages/nbconvert/__init__.py", line 7, in <module>
        from . import postprocessors
      File "/Users/davidlindo-atichati/miniconda3/envs/py3_parcels/lib/python3.7/site-packages/nbconvert/postprocessors/__init__.py", line 5, in <module>
        from .serve import ServePostProcessor
      File "/Users/davidlindo-atichati/miniconda3/envs/py3_parcels/lib/python3.7/site-packages/nbconvert/postprocessors/serve.py", line 19, in <module>
        class ProxyHandler(web.RequestHandler):
      File "/Users/davidlindo-atichati/miniconda3/envs/py3_parcels/lib/python3.7/site-packages/nbconvert/postprocessors/serve.py", line 21, in ProxyHandler
        @web.asynchronous
    AttributeError: module 'tornado.web' has no attribute 'asynchronous' [E 18:22:16.178 NotebookApp] {
      "Host": "localhost:8888",
      "Cookie": "username-localhost-8888=\"2|1:0|10:1551828040|23:username-localhost-8888|44:OGQ4ZTgzZDRjZjFiNDMzZDk0ZTI2NmJkMDc3OTEzMDk=|e4504cac3111242d53ab46ce3b8fa72750876a90bef7bc980a2ebb3c6f77caec\"; username-localhost-8889=\"2|1:0|10:1551821266|23:username-localhost-8889|44:ZjgyOTBhNTE3Zjg0NDJlOGIyNTA5NDRiNTBjMzQ0YTk=|43b122243108c4f7dbf37e636660b8d0656f5173d2b363a6bb496681de6d4e5f\";
_xsrf=2|0a22b984|8687c792155e13f5d476952db2d9f2f7|1551360338",
      "Connection": "keep-alive",
      "Upgrade-Insecure-Requests": "1",
      "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
      "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0.3 Safari/605.1.15",
      "Referer": "http://localhost:8888/tree",
      "Accept-Language": "en-us",
      "Accept-Encoding": "gzip, deflate"
    } [E 18:22:16.178 NotebookApp] 500 GET /notebooks/backtracking-sample-1.ipynb (::1) 121.50ms referer=http://localhost:8888/tree

笔记本在我的Safari浏览器中打开。但是,当我尝试打开现有笔记本或创建新笔记本时,在浏览器中收到“ 500:内部服务器错误”,并在终端上显示以下消息:

module.exports = (sequelize, DataTypes) => {
  const Role = sequelize.define("Role", {
    name: {
      type: DataTypes.STRING,
      allowNull: false
    },
    shortName: {
      type: DataTypes.STRING,
      allowNull: false
    }
  });
  Role.associate = function(models) {
    // associations can be defined here
    Role.hasMany(models.User, {
      as: "Users",
      foreignKey: "role_id",
      sourceKey: "id"
    });
  };
  return Role;
};

7 个答案:

答案 0 :(得分:2)

@tevemadar在您的情况下可能有正确的答案。龙卷风6+与Jupyter发生冲突。如果您编辑environment.yml以指定

dependencies:
-tornado<6

它为我解决了这个问题。

答案 1 :(得分:2)

我使用命令重新安装了nbcovert

conda install nbconvert=5.4.1

以上内容修复了“ 500:内部服务器错误”。但是,当我启动jupyter notebook时,它将拒绝连接到python内核,因此我不得不使用命令将tornado从v6.0.1降级到v5.1.1

conda install tornado=5.1.1 

在此之后,使用jupyter笔记本没有问题。

如果没有conda,则可以改用pip。

参考:Tornado 6问题讨论了herehere

答案 2 :(得分:1)

For me, the solution was to follow the suggestion of this link and apply a small edit to an nbconvert file.

详细来说,您需要修改文件_get_conf的函数nbconvert/exporters/templateexporter.py使其看起来像这样:

    def _get_conf(self):
        conf = {}  # the configuration once all conf files are merged
        for path in map(Path, self.template_paths):
            try:
                conf_path = path / 'conf.json'
                if conf_path.exists():
                    with conf_path.open() as f:
                        conf = recursive_update(conf, json.load(f))
            except:
                ## not important
                OK=1

        return conf

这是一个hack,希望将来对nbconvert的更新将提供永久的修复程序。

答案 3 :(得分:0)

这不是一个完美的答案。但是我还是会让你知道的。之所以发生这种情况,是因为我发现了某些软件包版本冲突。如果您卸载并重新安装Anaconda,它将起作用。它为我工作。

答案 4 :(得分:0)

使用命令安装 Jupyter 后:

pip install jupyter

尝试创建新笔记本时出现 500 错误。

通过命令重新安装 Jupyter 修复它:

pip3 install jupyter

答案 5 :(得分:-1)

非常感谢!!这确实帮助我使用此处和此处讨论的 Ref: Tornado 6 问题解决了该问题。定义 def _get_conf(self):也有帮助

答案 6 :(得分:-1)

另外,lindo atichati,这有效:pip install --upgrade nbconvert

并使用anaconda:conda upgrade nbconvert