【问题标题】:Spyder IDE fails to start on Windows 10 with Python 3.8 [duplicate]Spyder IDE 无法在带有 Python 3.8 的 Windows 10 上启动 [重复]
【发布时间】:2019-10-25 10:57:31
【问题描述】:

注意:此问题已在 Spyder 4.1.3 中修复!


(原始问题)在 Windows 10 上检查 Python 3.8 (x64),我在尝试设置 Spyder 时遇到了麻烦。注意:在干净的 Windows-10 系统上安装全新的 Python 可以重现该问题。但是,在 Linux 上没有此类问题(在 debian / Mint19.x 上测试)。

起初,通过pip install spyder 安装过程中一切顺利。


错误 #1: pywin32

启动Spyder后,在IPython控制台窗口中说:

Traceback (most recent call last):
File "c:\users\USERNAME\appdata\local\programs\python\python38\lib\site‑packages\spyder\plugins\ipythonconsole.py", line 1572, in create_kernel_manager_and_kernel_client
kernel_manager.start_kernel(stderr=stderr_handle)
File "c:\users\USERNAME\appdata\local\programs\python\python38\lib\site‑packages\jupyter_client\manager.py", line 240, in start_kernel
self.write_connection_file()
File "c:\users\USERNAME\appdata\local\programs\python\python38\lib\site‑packages\jupyter_client\connect.py", line 470, in write_connection_file
self.connection_file, cfg = write_connection_file(self.connection_file,
File "c:\users\USERNAME\appdata\local\programs\python\python38\lib\site‑packages\jupyter_client\connect.py", line 141, in write_connection_file
with secure_write(fname) as f:
File "c:\users\USERNAME\appdata\local\programs\python\python38\lib\contextlib.py", line 113, in __enter__
return next(self.gen)
File "c:\users\USERNAME\appdata\local\programs\python\python38\lib\site‑packages\jupyter_core\paths.py", line 424, in secure_write
win32_restrict_file_to_user(fname)
File "c:\users\USERNAME\appdata\local\programs\python\python38\lib\site‑packages\jupyter_core\paths.py", line 359, in win32_restrict_file_to_user
import win32api
ImportError: DLL load failed while importing win32api: Das angegebene Modul wurde nicht gefunden.

我可以通过从脚本文件夹运行pywin32_postinstall.py -install 来修复导入错误(从具有提升权限的cmd 提示符)。这会将pythoncom38.dllpywintypes38.dll\Lib\site-packages\pywin32_system32 复制到\windows\system32,另请参阅here - 但是,我建议不要修改 系统文件夹并使用我在@ 中输入的选项987654322@下方。


错误 #2: tornado

但是,现在Spyder 只是在加载屏幕上冻结(显示的徽标,上面写着“正在初始化主窗口”)!

https://github.com/spyder-ide/spyder.git 克隆Spyder 的开发版本并通过python bootstrap.py --debug 运行它揭示了冻结的原因:

2019-11-03 17:39:53,261 [ERROR] [tornado.application] -> Exception in callback functools.partial(<function ThreadedZMQSocketChannel.__init__.<locals>.setup_stream at 0x0000015E00B758B0>)
Traceback (most recent call last):
  File "C:\Users\USERNAME\AppData\Local\Programs\Python\Python38\lib\site-packages\tornado\ioloop.py", line 743, in _run_callback
    ret = callback()
  File "C:\Users\USERNAME\AppData\Local\Programs\Python\Python38\lib\site-packages\jupyter_client\threaded.py", line 48, in setup_stream
    self.stream = zmqstream.ZMQStream(self.socket, self.ioloop)
  File "C:\Users\USERNAME\AppData\Local\Programs\Python\Python38\lib\site-packages\zmq\eventloop\zmqstream.py", line 127, in __init__
    self._init_io_state()
  File "C:\Users\USERNAME\AppData\Local\Programs\Python\Python38\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\USERNAME\AppData\Local\Programs\Python\Python38\lib\site-packages\tornado\platform\asyncio.py", line 99, in add_handler
    self.asyncio_loop.add_reader(fd, self._handle_events, fd, IOLoop.READ)
  File "C:\Users\USERNAME\AppData\Local\Programs\Python\Python38\lib\asyncio\events.py", line 501, in add_reader
    raise NotImplementedError
NotImplementedError

...看来pywin32的Python 3.8版本导致的导入错误只是一个问题。还有一个与tornado IO(web server)相关的问题,见here/here

上次使用 Python 3.8.2 (AMD64)、Spyder 4.1.1 检查。请注意,我没有使用 Anaconda。使用conda pip,不要同时使用。

【问题讨论】:

标签: windows-10 tornado spyder pywin32 python-3.8


【解决方案1】:

Spyder 4.1.3 更新:问题已修复!

(在 Python 3.8.3rc1、tornado 6.0.4 上测试)

如果您来到这里仍然遇到与 Spyder 类似的启动问题:首先尝试我建议升级到 Spyder 版本 >= 4.1.3。。 p>


此答案的旧版本

解决方法,龙卷风问题:

修改文件...\Python38...\Lib\site-packages\tornado\platform\asyncio.py; 添加

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

在其他导入语句之后。来源:here on SO,也链接了here。如果我在tornado repo 上得到this 的帖子,这可能是一个相当永久的解决方法。


如果还需要 - 解决方法,pywin32 问题:

修改文件...\Python38\Lib\site-packages\jupyter_core\path.py; 添加一行

import pywintypes

之前 import win32api 在第 359 行。此修改基于 this 帖子。

【讨论】:

  • Yessssssssssssssssssssssssssssssssssssssssssssss!
  • 这个问题终于在我们昨天发布的 4.1.3 版本中得到修复。你能相应地更新你的答案吗?
  • @CarlosCordoba:是的,我很高兴昨天在新的 Win10 上安装了 Spyder 后发现了这一点!
  • 有没有办法使用 conda 命令将 python 3.7 升级到 3.8 或通过 anaconda navigator 进行处理?
猜你喜欢
  • 2019-08-14
  • 2019-07-15
  • 2021-07-07
  • 2019-08-02
  • 2020-07-03
  • 2020-09-04
  • 2017-12-10
  • 2020-03-27
  • 1970-01-01
相关资源
最近更新 更多