[英]Jupyter Notebook with Python 3.8 - NotImplementedError
Upgraded recently to Python 3.8, and installed jupyter
.最近升级到 Python 3.8,并安装了
jupyter
。 However, when trying to run jupyter notebook
getting the following error:但是,当尝试运行
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 ProactorEventLoop
by default, so I suspect it is related to this.我知道 windows 上的 Python 3.8 默认切换到
ProactorEventLoop
,所以我怀疑它与此有关。
Jupyter does not support Python 3.8 at the moment? Jupyter 目前不支持 Python 3.8? Is there a work around?
有解决办法吗?
EDIT编辑
This issue exists in older versions of Jupyter Notebook and was fixed in version 6.0.3 (released 2020-01-21).此问题存在于旧版本的 Jupyter Notebook 中,并已在版本6.0.3 (2020-01-21 发布)中修复。 To upgrade to the latest version run:
要升级到最新版本,请运行:
pip install notebook --upgrade
Following on this issue through GitHub, it seems the problem is related to the
tornado
server that jupyter uses.
通过 GitHub 关注这个问题,似乎问题与 jupyter 使用的
tornado
服务器有关。
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:对于那些等不及官方修复的人,我可以通过编辑文件
tornado/platform/asyncio.py
来使其工作,方法是添加:
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.不过,我预计很快就会对此进行官方修复。
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__
For me, I had to reinstall asyncio对我来说,我不得不重新安装 asyncio
pip install asyncio --upgrade
And upgrade the kernel package并升级kernel package
pip install ipykernel --upgrade
I solved this problem by changing the python version from 3.9 to 3.7.我通过将 python 版本从 3.9 更改为 3.7 解决了这个问题。 (Windows).
(视窗)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.