Anaconda 4.8.2 中的 QT 控制台和 spyder Python 3.8.x 从 asyncio\events.py 引发了 NotImplementedError

QT Console and spyder in Anaconda 4.8.2 with Python 3.8.x raised NotImplementedError from asyncio\events.py

我使用 AnacondaNavigator 在 Anaconda (Windows X) 中创建了一个新环境。环境名为 py3_8_20200407 并具有 Python 3.8.xSpyder 4.x .当我启动 Spyder 时,新打开的 Spyder window 会在一段时间后冻结并且没有响应。如果我尝试使用 QT 控制台,我会得到如下相同的错误:(显示的输出来自 spyder --debug-info verbose

2020-04-07 16:56:19,075 [INFO] [spyder.app.mainwindow] -> Deleting previous Spyder instance LSP logs...
2020-04-07 16:56:19,127 [DEBUG] [traitlets] -> Using default logger
2020-04-07 16:56:19,239 [INFO] [spyder.plugins.ipythonconsole.utils.kernelspec] -> Kernel command: ['C:\Users\me\.conda\envs\py3_8_20200407\python.exe', '-m', 'spyder_kernels.console', '-f', '{connection_file}']
2020-04-07 16:56:19,240 [DEBUG] [traitlets] -> Starting kernel: ['C:\Users\me\.conda\envs\py3_8_20200407\python.exe', '-m', 'spyder_kernels.console', '-f', 'C:\Users\me\AppData\Roaming\jupyter\runtime\kernel-3964ff42f733.json']
2020-04-07 16:56:19,249 [DEBUG] [traitlets] -> Connecting to: tcp://127.0.0.1:57565
2020-04-07 16:56:19,258 [DEBUG] [traitlets] -> connecting heartbeat channel to tcp://127.0.0.1:57566
2020-04-07 16:56:19,261 [DEBUG] [asyncio] -> Using proactor: IocpProactor
2020-04-07 16:56:19,262 [DEBUG] [asyncio] -> Using proactor: IocpProactor
2020-04-07 16:56:19,263 [DEBUG] [traitlets] -> connecting shell channel to tcp://127.0.0.1:57562
2020-04-07 16:56:19,263 [DEBUG] [traitlets] -> Connecting to: tcp://127.0.0.1:57562
2020-04-07 16:56:19,270 [ERROR] [tornado.application] -> Exception in callback functools.partial(<function ThreadedZMQSocketChannel.__init__.<locals>.setup_stream at 0x0000024B9D406E50>)
Traceback (most recent call last):
  File "C:\Users\me\.conda\envs\py3_8_20200407\lib\site-packages\tornado\ioloop.py", line 743, in _run_callback
    ret = callback()
  File "C:\Users\me\.conda\envs\py3_8_20200407\lib\site-packages\jupyter_client\threaded.py", line 47, in setup_stream
    self.stream = zmqstream.ZMQStream(self.socket, self.ioloop)
  File "C:\Users\me\.conda\envs\py3_8_20200407\lib\site-packages\zmq\eventloop\zmqstream.py", line 127, in __init__
    self._init_io_state()
  File "C:\Users\me\.conda\envs\py3_8_20200407\lib\site-packages\zmq\eventloop\zmqstream.py", line 546, in _init_io_state
    self.io_loop.add_handler(self.socket, self._handle_events, self.io_loop.READ)
  File "C:\Users\me\.conda\envs\py3_8_20200407\lib\site-packages\tornado\platform\asyncio.py", line 100, in add_handler
    self.asyncio_loop.add_reader(fd, self._handle_events, fd, IOLoop.READ)
  File "C:\Users\me\.conda\envs\py3_8_20200407\lib\asyncio\events.py", line 501, in add_reader
    raise NotImplementedError
NotImplementedError

我在其他线程中提出了令人厌烦的解决方法。但是 asincio.py 已经包含

import sys

if sys.platform == 'win32' and hasattr(asyncio, "WindowsSelectorEventLoopPolicy"):
    asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())

我尝试了不同版本的 Python,只有 <= 3.7.7 的版本适用于 Spyder 4。1.x

(此处为 Spyder 维护者) QtConsole 和 Spyder 目前(2020 年 4 月)都无法使用 Python 3.8。但是,我们会尝试在月底发布新版本来解决您在上面发布的问题。