Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Asyncio NotImplemented Error after Python 3.8.0 #1885

Closed
cryocaustik opened this issue Oct 17, 2019 · 18 comments · Fixed by #1922
Closed

Asyncio NotImplemented Error after Python 3.8.0 #1885

cryocaustik opened this issue Oct 17, 2019 · 18 comments · Fixed by #1922
Labels
Milestone

Comments

@cryocaustik
Copy link

Using a new install of Python 3.8.0, pip installed latest version of MkDocs, and then tried to run mkdocs serve, which encountered the below error.

I tried again on a new docs directory (mkdocs new testing), but encountered the same issue again.

Python version: 3.8.0
OS: Windows 10 Pro v1709

error:

C:\dev\testing
λ  mkdocs serve
INFO    -  Building documentation...
INFO    -  Cleaning site directory
[I 191017 14:49:48 server:296] Serving on http://127.0.0.1:8000
Traceback (most recent call last):
  File "c:\users\aleksandr.skobelev\appdata\local\programs\python\python38\lib\runpy.py", line 192, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\users\aleksandr.skobelev\appdata\local\programs\python\python38\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\aleksandr.skobelev\AppData\Local\Programs\Python\Python38\Scripts\mkdocs.exe\__main__.py", line 9, in <module>
  File "c:\users\aleksandr.skobelev\appdata\local\programs\python\python38\lib\site-packages\click\core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "c:\users\aleksandr.skobelev\appdata\local\programs\python\python38\lib\site-packages\click\core.py", line 717, in main
    rv = self.invoke(ctx)
  File "c:\users\aleksandr.skobelev\appdata\local\programs\python\python38\lib\site-packages\click\core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "c:\users\aleksandr.skobelev\appdata\local\programs\python\python38\lib\site-packages\click\core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "c:\users\aleksandr.skobelev\appdata\local\programs\python\python38\lib\site-packages\click\core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "c:\users\aleksandr.skobelev\appdata\local\programs\python\python38\lib\site-packages\mkdocs\__main__.py", line 128, in serve_command
    serve.serve(
  File "c:\users\aleksandr.skobelev\appdata\local\programs\python\python38\lib\site-packages\mkdocs\commands\serve.py", line 124, in serve
    _livereload(host, port, config, builder, site_dir)
  File "c:\users\aleksandr.skobelev\appdata\local\programs\python\python38\lib\site-packages\mkdocs\commands\serve.py", line 58, in _livereload
    server.serve(root=site_dir, host=host, port=port, restart_delay=0)
  File "c:\users\aleksandr.skobelev\appdata\local\programs\python\python38\lib\site-packages\livereload\server.py", line 298, in serve
    self.application(
  File "c:\users\aleksandr.skobelev\appdata\local\programs\python\python38\lib\site-packages\livereload\server.py", line 253, in application
    app.listen(port, address=host)
  File "c:\users\aleksandr.skobelev\appdata\local\programs\python\python38\lib\site-packages\tornado\web.py", line 2112, in listen
    server.listen(port, address)
  File "c:\users\aleksandr.skobelev\appdata\local\programs\python\python38\lib\site-packages\tornado\tcpserver.py", line 152, in listen
    self.add_sockets(sockets)
  File "c:\users\aleksandr.skobelev\appdata\local\programs\python\python38\lib\site-packages\tornado\tcpserver.py", line 165, in add_sockets
    self._handlers[sock.fileno()] = add_accept_handler(
  File "c:\users\aleksandr.skobelev\appdata\local\programs\python\python38\lib\site-packages\tornado\netutil.py", line 279, in add_accept_handler
    io_loop.add_handler(sock, accept_handler, IOLoop.READ)
  File "c:\users\aleksandr.skobelev\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\aleksandr.skobelev\appdata\local\programs\python\python38\lib\asyncio\events.py", line 501, in add_reader
    raise NotImplementedError
NotImplementedError
@waylan
Copy link
Member

waylan commented Oct 17, 2019

Thanks for the report. This appears to be related to tornadoweb/tornado#2608. I'm assuming this will need to be fixed by lepture/python-livereload. However, I don't see any reports there yet and I don't have a way to test this on Windows myself. If anyone can confirm this error exists in plain python-livereload on Windows, please report this upstream to that project. We will determine how to proceed based on that.

@minhluan259
Copy link

+1
I've same error

@waylan
Copy link
Member

waylan commented Oct 25, 2019

As a test could someone who is getting the error confirm that the error also occurs when running these commands:

mkdocs build
livereload site

That runs livereload directly without MkDocs light wrapper. My expectation is that the error will also occur there. If it does, the error needs to be reported upstream to that project to be fixed. If it does not occur there, then we will fix it in MkDocs.

@waylan waylan added this to the 1.1 milestone Oct 25, 2019
@SaDiablo
Copy link

Python version:

E:\Sync\SKN\Projekty\2019_03_Roboty` Mobilne 1\Pliki\AlphaBot2>python --version
Python 3.8.0

mkdocs build command

E:\Sync\SKN\Projekty\2019_03_Roboty Mobilne 1\Pliki\AlphaBot2>mkdocs build
INFO    -  Cleaning site directory
INFO    -  Building documentation to directory: E:\Sync\SKN\Projekty\2019_03_Roboty Mobilne 1\Pliki\AlphaBot2\site

livereload site command

E:\Sync\SKN\Projekty\2019_03_Roboty Mobilne 1\Pliki\AlphaBot2>livereload site
[I 191026 22:40:22 server:296] Serving on http://127.0.0.1:35729
Traceback (most recent call last):
  File "c:\program files\python38\lib\runpy.py", line 192, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\program files\python38\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Program Files\Python38\Scripts\livereload.exe\__main__.py", line 7, in <module>
  File "c:\program files\python38\lib\site-packages\livereload\cli.py", line 60, in main
    server.serve(host=args.host, port=args.port, root=args.directory,
  File "c:\program files\python38\lib\site-packages\livereload\server.py", line 298, in serve
    self.application(
  File "c:\program files\python38\lib\site-packages\livereload\server.py", line 253, in application
    app.listen(port, address=host)
  File "c:\program files\python38\lib\site-packages\tornado\web.py", line 2112, in listen
    server.listen(port, address)
  File "c:\program files\python38\lib\site-packages\tornado\tcpserver.py", line 152, in listen
    self.add_sockets(sockets)
  File "c:\program files\python38\lib\site-packages\tornado\tcpserver.py", line 165, in add_sockets
    self._handlers[sock.fileno()] = add_accept_handler(
  File "c:\program files\python38\lib\site-packages\tornado\netutil.py", line 279, in add_accept_handler
    io_loop.add_handler(sock, accept_handler, IOLoop.READ)
  File "c:\program files\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:\program files\python38\lib\asyncio\events.py", line 501, in add_reader
    raise NotImplementedError
NotImplementedError

@waylan
Copy link
Member

waylan commented Oct 27, 2019

@SaDiablo thanks for the update. I have used your error message to report the issue upstream to lepture/python-livereload#209. When we get a response there, it will inform us how to proceed here.

@xDavex
Copy link

xDavex commented Nov 12, 2019

It happened the same to me once I updated the pip version using Chocolatey

PS C:\Users\daja0716\Seafile\Sync\Backup\my-wiki> python --version
Python 3.8.0

PS C:\Users\daja0716\Seafile\Sync\Backup\my-wiki> pip --version
pip 19.3.1 from c:\python38\lib\site-packages\pip (python 3.8)

OS: Windows 10 v1903

PS C:\Users\daja0716\Seafile\Sync\Backup\my-wiki> mkdocs serve
INFO    -  Building documentation...
INFO    -  Cleaning site directory
[I 191112 17:08:24 server:296] Serving on http://127.0.0.1:8000
Traceback (most recent call last):
  File "c:\python38\lib\runpy.py", line 192, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\python38\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Python38\Scripts\mkdocs.exe\__main__.py", line 7, in <module>
  File "c:\python38\lib\site-packages\click\core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "c:\python38\lib\site-packages\click\core.py", line 717, in main
    rv = self.invoke(ctx)
  File "c:\python38\lib\site-packages\click\core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "c:\python38\lib\site-packages\click\core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "c:\python38\lib\site-packages\click\core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "c:\python38\lib\site-packages\mkdocs\__main__.py", line 128, in serve_command
    serve.serve(
  File "c:\python38\lib\site-packages\mkdocs\commands\serve.py", line 124, in serve
    _livereload(host, port, config, builder, site_dir)
  File "c:\python38\lib\site-packages\mkdocs\commands\serve.py", line 58, in _livereload
    server.serve(root=site_dir, host=host, port=port, restart_delay=0)
  File "c:\python38\lib\site-packages\livereload\server.py", line 298, in serve
    self.application(
  File "c:\python38\lib\site-packages\livereload\server.py", line 253, in application
    app.listen(port, address=host)
  File "c:\python38\lib\site-packages\tornado\web.py", line 2112, in listen
    server.listen(port, address)
  File "c:\python38\lib\site-packages\tornado\tcpserver.py", line 152, in listen
    self.add_sockets(sockets)
  File "c:\python38\lib\site-packages\tornado\tcpserver.py", line 165, in add_sockets
    self._handlers[sock.fileno()] = add_accept_handler(
  File "c:\python38\lib\site-packages\tornado\netutil.py", line 279, in add_accept_handler
    io_loop.add_handler(sock, accept_handler, IOLoop.READ)
  File "c:\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:\python38\lib\asyncio\events.py", line 501, in add_reader
    raise NotImplementedError
NotImplementedError

When running the

mkdocs build
livereload site
PS C:\Users\daja0716\Seafile\Sync\Backup\my-wiki> mkdocs build
INFO    -  Cleaning site directory
INFO    -  Building documentation to directory: C:\Users\daja0716\Seafile\Sync\Backup\my-wiki\site
PS C:\Users\daja0716\Seafile\Sync\Backup\my-wiki> livereload site
[I 191112 17:15:15 server:296] Serving on http://127.0.0.1:35729
Traceback (most recent call last):
  File "c:\python38\lib\runpy.py", line 192, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\python38\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Python38\Scripts\livereload.exe\__main__.py", line 9, in <module>
  File "c:\python38\lib\site-packages\livereload\cli.py", line 60, in main
    server.serve(host=args.host, port=args.port, root=args.directory,
  File "c:\python38\lib\site-packages\livereload\server.py", line 298, in serve
    self.application(
  File "c:\python38\lib\site-packages\livereload\server.py", line 253, in application
    app.listen(port, address=host)
  File "c:\python38\lib\site-packages\tornado\web.py", line 2112, in listen
    server.listen(port, address)
  File "c:\python38\lib\site-packages\tornado\tcpserver.py", line 152, in listen
    self.add_sockets(sockets)
  File "c:\python38\lib\site-packages\tornado\tcpserver.py", line 165, in add_sockets
    self._handlers[sock.fileno()] = add_accept_handler(
  File "c:\python38\lib\site-packages\tornado\netutil.py", line 279, in add_accept_handler
    io_loop.add_handler(sock, accept_handler, IOLoop.READ)
  File "c:\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:\python38\lib\asyncio\events.py", line 501, in add_reader
    raise NotImplementedError
NotImplementedError

@waylan
Copy link
Member

waylan commented Nov 12, 2019

Yes, we know it is a problem. However, the problem is upstream and we can only wait for it to be fixed there. Adding "me too" reports will not change that.

@f0f0-cr
Copy link

f0f0-cr commented Dec 4, 2019

If you have PHP installed, then you can build and then serve

mkdocs build
php -S 127.0.0.1:8000

If you made any change then open a new cmd and rebuild

mkdocs build

@waylan
Copy link
Member

waylan commented Dec 8, 2019

I just noticed lepture/python-livereload includes the text "MAINTAINERS NEEDED" in the Project Description at the top of the page. Given that no response has been made even if just to answer the question of how Python-Livereload plans to move forward, I think we will need to provide our own solution. However, it should be done in such a way that any upstream fix won't create a problem.

waylan added a commit to waylan/mkdocs that referenced this issue Dec 8, 2019
As of Python 3.8, the default event loop on Windows is `proactor`,
however Tornado requires the old default "selector" event loop.
As Tornado has decided to leave this to users to set, MkDocs needs
to set it. See tornadoweb/tornado#2608.

Fixes mkdocs#1885.
@waylan
Copy link
Member

waylan commented Dec 8, 2019

I just pushed a fix to #1922, However, I do not have a system available to test this on. Any feed back from someone who has experienced the error would be helpful.

waylan added a commit to waylan/mkdocs that referenced this issue Dec 8, 2019
As of Python 3.8, the default event loop on Windows is `proactor`,
however Tornado requires the old default "selector" event loop.
As Tornado has decided to leave this to users to set, MkDocs needs
to set it. See tornadoweb/tornado#2608.

Fixes mkdocs#1885.
@fendttobias
Copy link

This fix seems to work

I experienced the issue too and patched cf2b136 as my serve.py for testing. I can confirm that mkdocs serve is working now.

I hope I'm doing this right as I'm just starting to use mkdocs or github.
Maybe someone else can confirm too?

@waylan
Copy link
Member

waylan commented Dec 12, 2019

@fendttobias thanks for the feedback. Due to the nature of the issue, the only way it could be working is if you applied the patch correctly. That is very helpful.

waylan added a commit that referenced this issue Dec 12, 2019
As of Python 3.8, the default event loop on Windows is `proactor`,
however Tornado requires the old default "selector" event loop.
As Tornado has decided to leave this to users to set, MkDocs needs
to set it. See tornadoweb/tornado#2608.

Fixes #1885.
@root-ansh
Copy link

I am facing the original problem of NotImplementedError . (mkdocs version 1.0.4) i am not sure if i have the patch installed. can someone guide me how to install that patch (or in other case, check if the patch is already installed)?
i have just refreshed my system and installed python,mkdocs and mkdocs material just now. Trying to open an old mkdocs project from september -19

@waylan
Copy link
Member

waylan commented Jan 4, 2020

@root-ansh the patch has been applied to the master branch here on Github and will be included in the next release. If you want to apply the patch manually, then you will need to modify the source code by applying the changes in 2172c9f before installing it.

@root-ansh
Copy link

root-ansh commented Jan 5, 2020

Thanks for explaining, @waylan . When can we expect the next release?

@waylan
Copy link
Member

waylan commented Jan 5, 2020

MkDocs is developed by volunteers in our spare time. Therefore it is impossible to provide a timeline. The best I can say it that the next release will be released when it is ready.

If you would like to help move things along, the 1.1 milestone provides a list of items which need to be resolved before the release is made.

gianpag referenced this issue in gianpag/MongoDBAtlas-IBM-AIMLv2 Jan 22, 2020
…do work with windows 10 and up

import asyncio

if sys.platform == 'win32':
    asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
@ghost
Copy link

ghost commented Jan 29, 2020

This fix seems to work

I experienced the issue too and patched cf2b136 as my serve.py for testing. I can confirm that mkdocs serve is working now.

I hope I'm doing this right as I'm just starting to use mkdocs or github.
Maybe someone else can confirm too?

Confirmed. I am on Windows 10 1809 and I used source code from 2172c9f to edit serve.py. After restarting vscode and running mkdocs serve command I'm able to browse site on localhost:8000. Thank you mkdocs team for providing a fix.

@Konstantin-Ushakov
Copy link

Konstantin-Ushakov commented May 19, 2021

I get this error when try to run streamlit on Windows 10 using Python 3.9:

c:\users\XXX\appdata\local\programs\python\python39\lib\asyncio\events.py", line 504, in add_reader
    raise NotImplementedError

Find a solution to myself refer to Jupyter Notebook with Python 3.8 - NotImplementedError on similar question.

pip install notebook --upgrade

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants