注意:此问题已在 Spyder 4.1.3 中修复!
(原始问题)在 Windows 10 上检查 Python 3.8 (x64),我在尝试 setup 时遇到了麻烦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.dll
和pywintypes38.dll
from \Lib\site-packages\pywin32_system32
to \windows\system32
,另请参见此处-但是,我建议不要修改系统文件夹并使用我在下面的答案中输入的选项。
错误 #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
...所以看来由 Python 3.8 版本引起的导入错误pywin32
只是一个问题。还有一个与tornado
IO(Web 服务器)相关的问题,请参见此处/此处。
最后使用 Python 3.8.2 (AMD64)、Spyder 4.1.1 检查。请注意,我没有使用 Anaconda。使用其中一个
conda
或pip
,不要同时使用。