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

2024-04-19 07:02:17 发布

您现在位置:Python中文网/ 问答频道 /正文

我用Anaconda Vigator在Anaconda(Windows X)中创建了一个新环境。该环境名为py3_8_20200407,具有Python 3.8.xSpyder 4.x。当我启动Spyder时,新打开的Spyder窗口会在一段时间后冻结并没有响应。如果我尝试使用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


Tags: inpydebugselfasyncioliblinepy3