带有 Python 3.8 的 Jupyter Notebook - NotImplementedError
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/58422817/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Jupyter Notebook with Python 3.8 - NotImplementedError
提问by drec4s
Upgraded recently to Python 3.8, and installed jupyter. However, when trying to run jupyter notebookgetting the following error:
最近升级到 Python 3.8,并安装了jupyter. 但是,尝试运行时jupyter notebook出现以下错误:
File "c:\users\user\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\user\appdata\local\programs\python\python38\lib\asyncio\events.py", line 501, in add_reader
raise NotImplementedError
NotImplementedError
I know Python 3.8 on windows switched to ProactorEventLoopby default, so I suspect it is related to this.
我知道 Windows 上的 Python 3.8ProactorEventLoop默认切换到,所以我怀疑它与此有关。
Jupyter does not support Python 3.8 at the moment? Is there a work around?
Jupyter 目前不支持 Python 3.8?有解决办法吗?
回答by drec4s
EDIT
编辑
This issue exists in older versions of Jupyter Notebook and was fixed in version 6.0.3(released 2020-01-21). To upgrade to the latest version run:
此问题存在于旧版 Jupyter Notebook 中,并在6.0.3版(2020 年 1 月 21 日发布)中修复。要升级到最新版本,请运行:
pip install notebook --upgrade
Following on this issue through GitHub, it seems the problem is related to the tornadoserver that jupyter uses.
通过GitHub关注此问题,似乎问题与tornadojupyter使用的服务器有关。
For those that can't wait for an official fix, I was able to get it working by editing the file tornado/platform/asyncio.py, by adding:
import sys
if sys.platform == 'win32':
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
After the main imports.
I expect an official fix for this soon, however.
对于那些等不及官方修复的人,我可以通过编辑文件来使其工作tornado/platform/asyncio.py,添加:
import sys
if sys.platform == 'win32':
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
后主要进口。
不过,我预计很快就会对此进行正式修复。
回答by Mirwise Khan
Revising the answer in 2019
2019年的答案修改
Change the end part of the file
C:\Users\{USER-NAME}\AppData\Local\Programs\Python\Python38\Lib\asyncio\__init__.py
更改文件的结尾部分
C:\Users\{USER-NAME}\AppData\Local\Programs\Python\Python38\Lib\asyncio\__init__.py
From
从
if sys.platform == 'win32': # pragma: no cover
from .windows_events import *
__all__ += windows_events.__all__
else:
from .unix_events import * # pragma: no cover
__all__ += unix_events.__all__
To
到
import asyncio
if sys.platform == 'win32':
from .windows_events import *
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
__all__ += windows_events.__all__
else:
from .unix_events import * # pragma: no cover
__all__ += unix_events.__all__

