Jupyter Notebook with Python 3.8 – NotImplementedError

Upgraded recently to Python 3.8, and installed jupyter. However, when trying to run jupyter notebook getting the following error:

  File "c:usersuserappdatalocalprogramspythonpython38libsite-packagestornadoplatformasyncio.py", line 99, in add_handler
    self.asyncio_loop.add_reader(fd, self._handle_events, fd, IOLoop.READ)
  File "c:usersuserappdatalocalprogramspythonpython38libasyncioevents.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.

Jupyter does not support Python 3.8 at the moment? Is there a work around?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

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:

pip install notebook --upgrade

Following on this issue through GitHub, it seems the problem is related to the tornado server that jupyter uses.

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.

Method 2

Revising the answer in 2019

Change the end part of the file
C:Users{USER-NAME}AppDataLocalProgramsPythonPython38Libasyncio__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__

Method 3

For me, I had to reinstall asyncio

pip install asyncio --upgrade

And upgrade the kernel package

pip install ipykernel --upgrade

Method 4

I solved this problem by changing the python version from 3.9 to 3.7. (Windows).


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x