简体   繁体   English

带有 Python 3.8 的 Jupyter 笔记本 - NotImplementedError

[英]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.

相关问题 如何在 Jupyter Notebook 中将 python 升级到 3.8? - How can I upgrade python to 3.8 in Jupyter Notebook? Jupyter notebook 在我的机器上使用了与默认 python 版本 (Python 3.9) 不同的内核 (python 3.8) - Jupyter notebook is using different Kernel (python 3.8) from my default python version (Python 3.9) in my machine pip3 指向 python 3.8 和 jupyter notebook 指向 python 3.9。 无法同步两者 - pip3 points to python 3.8 and jupyter notebook points to python 3.9. Having trouble syncing the two "当我尝试使用 Python 3.8 在 jupyter notebook 中安装 PySimpleGUI (4.53.0) 时,错误“没有返回名为‘PySimpleGUI’的模块" - When I try to install PySimpleGUI (4.53.0) in jupyter notebook using Python 3.8 the error "no module named 'PySimpleGUI' is returned TAB 完成在 jupyter 笔记本中不起作用并给出错误“NotImplementedError” - TAB completion not working in jupyter notebook and giving the error "NotImplementedError" 在jupyter笔记本中没有python终端 - No python terminal in jupyter notebook python jupyter 笔记本中的 AttributeError - AttributeError in python jupyter notebook Python 中的 Jupyter 笔记本 - Jupyter Notebook In Python 用python 3运行Jupyter笔记本 - Running Jupyter notebook with python 3 Jupyter Notebook - 安装 python 2 - Jupyter Notebook - install python 2
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM