1

我正在尝试在 Atom 上运行 Hydrogen,但在 asyncio python 库中收到一条以“NotImplementedError”结尾的错误消息。

我在 Windows 10 机器上安装了 Python3,并且我用 jupyter 安装了 ipython 内核。

我收到以下错误消息,我不确定从哪里开始解决问题。

回溯(最近一次调用最后):文件“C:\Users\chels\AppData\Local\Programs\Python\Python38\lib\runpy.py”,第 192 行,在 _run_module_as_main 返回 _run_code(code, main_globals, None, File" C:\Users\chels\AppData\Local\Programs\Python\Python38\lib\runpy.py”,第 85 行,在 _run_code exec(code, run_globals) 文件“C:\Users\chels\AppData\Local\Programs\ Python\Python38\lib\site-packages\ipykernel_launcher.py”,第 16 行,在 app.launch_new_instance() 文件“C:\Users\chels\AppData\Local\Programs\Python\Python38\lib\site-packages\traitlets \config\application.py",第 657 行,在 launch_instance app.initialize(argv) 文件中"",第 2 行,在初始化文件中"C:\Users\chels\AppData\Local\Programs\Python\Python38\lib\site -packages\traitlets\config\application.py”,第 87 行,在 catch_config_error 返回方法(app、*args、**kwargs)文件“C:\Users\chels\AppData\Local\Programs\Python\Python38\lib\site-packages\ipykernel\kernelapp.py”中,第 469 行初始化 self.init_sockets() 文件“C:\Users\chels\AppData\Local\Programs\Python\Python38\lib\site-packages\ipykernel\kernelapp.py”,第 259 行,在 init_sockets self.init_iopub(context) 文件中“C:\Users\chels\AppData\Local\Programs\Python\Python38\lib\site-packages\ipykernel\kernelapp.py”,第 267 行,在 init_iopub self.iopub_thread = IOPubThread(self.iopub_socket, pipe=True)文件“C:\Users\chels\AppData\Local\Programs\Python\Python38\lib\site-packages\ipykernel\iostream.py”,第 68 行,在 init self._setup_pipe_in() 文件“C:\Users\chels \AppData\Local\Programs\Python\Python38\lib\site-packages\ipykernel\iostream.py”,第 141 行,在 _setup_pipe_in self._pipe_in = ZMQStream(pipe_in, self.io_loop) 文件“C:\Users\chels\AppData\Local\Programs\Python\Python38\lib\site-packages\zmq\eventloop\zmqstream.py”,第 120 行,在 init self._init_io_state() 文件“C:\Users\chels\AppData\Local\Programs\Python\Python38\lib\site-packages\zmq\eventloop\zmqstream.py”中,第 541 行,在 _init_io_state self.io_loop .add_handler(self.socket, self._handle_events, self.io_loop.READ) 文件“C:\Users\chels\AppData\Local\Programs\Python\Python38\lib\site-packages\tornado\platform\asyncio.py” ,第 79 行,在 add_handler self.asyncio_loop.add_reader(文件“C:\Users\chels\AppData\Local\Programs\Python\Python38\lib\asyncio\events.py”,第 498 行,在 add_reader 中引发 NotImplementedError NotImplementedError\Users\chels\AppData\Local\Programs\Python\Python38\lib\site-packages\zmq\eventloop\zmqstream.py”,第 120 行,在 init self._init_io_state() 文件“C:\Users\chels\AppData \Local\Programs\Python\Python38\lib\site-packages\zmq\eventloop\zmqstream.py",第 541 行,在 _init_io_state self.io_loop.add_handler(self.socket, self._handle_events, self.io_loop.READ) 文件中“C:\Users\chels\AppData\Local\Programs\Python\Python38\lib\site-packages\tornado\platform\asyncio.py”,第 79 行,在 add_handler self.asyncio_loop.add_reader(文件“C:\Users \chels\AppData\Local\Programs\Python\Python38\lib\asyncio\events.py",第 498 行,在 add_reader 中引发 NotImplementedError NotImplementedError\Users\chels\AppData\Local\Programs\Python\Python38\lib\site-packages\zmq\eventloop\zmqstream.py”,第 120 行,在 init self._init_io_state() 文件“C:\Users\chels\AppData \Local\Programs\Python\Python38\lib\site-packages\zmq\eventloop\zmqstream.py",第 541 行,在 _init_io_state self.io_loop.add_handler(self.socket, self._handle_events, self.io_loop.READ) 文件中“C:\Users\chels\AppData\Local\Programs\Python\Python38\lib\site-packages\tornado\platform\asyncio.py”,第 79 行,在 add_handler self.asyncio_loop.add_reader(文件“C:\Users \chels\AppData\Local\Programs\Python\Python38\lib\asyncio\events.py",第 498 行,在 add_reader 中引发 NotImplementedError NotImplementedError\Users\chels\AppData\Local\Programs\Python\Python38\lib\site-packages\zmq\eventloop\zmqstream.py",第 541 行,在 _init_io_state self.io_loop.add_handler(self.socket, self._handle_events, self .io_loop.READ) 文件“C:\Users\chels\AppData\Local\Programs\Python\Python38\lib\site-packages\tornado\platform\asyncio.py”,第 79 行,在 add_handler self.asyncio_loop.add_reader(文件“C:\Users\chels\AppData\Local\Programs\Python\Python38\lib\asyncio\events.py”,第 498 行,在 add_reader 中引发 NotImplementedError NotImplementedError\Users\chels\AppData\Local\Programs\Python\Python38\lib\site-packages\zmq\eventloop\zmqstream.py",第 541 行,在 _init_io_state self.io_loop.add_handler(self.socket, self._handle_events, self .io_loop.READ) 文件“C:\Users\chels\AppData\Local\Programs\Python\Python38\lib\site-packages\tornado\platform\asyncio.py”,第 79 行,在 add_handler self.asyncio_loop.add_reader(文件“C:\Users\chels\AppData\Local\Programs\Python\Python38\lib\asyncio\events.py”,第 498 行,在 add_reader 中引发 NotImplementedError NotImplementedErrorpy”,第 79 行,在 add_handler self.asyncio_loop.add_reader(文件“C:\Users\chels\AppData\Local\Programs\Python\Python38\lib\asyncio\events.py”,第 498 行,在 add_reader 中引发 NotImplementedError NotImplementedErrorpy”,第 79 行,在 add_handler self.asyncio_loop.add_reader(文件“C:\Users\chels\AppData\Local\Programs\Python\Python38\lib\asyncio\events.py”,第 498 行,在 add_reader 中引发 NotImplementedError NotImplementedError

4

3 回答 3

1

异常来自 Tornado 调用add_readerWindows 不支持的 asyncio 事件循环方法。

Tornado 文档说明了有关平台的以下内容:

平台: Tornado 应该在任何类 Unix 平台上运行,尽管为了获得最佳性能和可扩展性,仅建议将 Linux (with epoll) 和 BSD (with kqueue) 用于生产部署(尽管 Mac OS X 源自 BSD 并支持 kqueue,它的网络性能通常很差,因此建议仅用于开发用途)。Tornado 也将在 Windows 上运行,尽管此配置不受官方支持,仅建议用于开发用途。如果不重新设计 Tornado IOLoop 接口,就无法添加原生 Tornado Windows IOLoop 实现或利用来自 AsyncIO 或 Twisted 等框架的 Windows IOCP 支持。

最后一句表示 Tornado 的 asyncio 部分还不能在 Windows 上运行。

于 2019-02-09T17:05:41.440 回答
0

您可以回滚到 Python 3.7,也可以编辑 Tornado 以在 3.8 上工作。

找到tornado/platform/asyncio.py文件,添加如下代码:

import sys

if sys.platform == 'win32':
    asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())

这里

于 2019-11-26T15:51:41.860 回答
0

您需要将其添加到 C:\Users\username\AppData\Local\Programs\Python\Python38\Lib\site-packages\tornado\platform

import asyncio
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())  # python-3.8.0a4

于 2019-12-17T18:57:53.093 回答