(原始问题)在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
从scripts文件夹运行(cmd
具有提升权限的提示符)来修复导入错误。该复制pythoncom38.dll
和pywintypes38.dll
从\Lib\site-packages\pywin32_system32
到\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服务器)有关的问题,请参阅here / here。
最后使用Python 3.8.2(AMD64),Spyder 4.1.1检查。请注意,我没有使用Anaconda。使用
conda
或之一pip
,不要同时使用。
(在Python 3.8.3rc1,龙卷风6.0.4上测试)
如果您来到这里仍然遇到Spyder的类似启动问题:尝试的第一件事,我建议升级到Spyder版本> = 4.1.3。
此答案的旧版本
解决方法,龙卷风问题:
修改文件...\Python38...\Lib\site-packages\tornado\platform\asyncio.py
;加
import sys
if sys.platform == 'win32':
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
在其他import语句之后。来源:在SO上也可以在此处链接。如果我在回购权上获得此职位tornado
,这可能是一个永久的解决方法。
如果还需要-解决方法,pywin32问题:
修改文件...\Python38\Lib\site-packages\jupyter_core\path.py
;加一行
import pywintypes
import win32api
在359行之前。此修改基于此文章。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句