#32103: runserver: NotImplementedError (with Python 3.8 on Windows)
-------------------------------------+-------------------------------------
               Reporter:  Andrey     |          Owner:  nobody
  Zelenchuk                          |
                   Type:  Bug        |         Status:  new
              Component:  Core       |        Version:  3.1
  (Management commands)              |
               Severity:  Release    |       Keywords:
  blocker                            |
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 The `runserver` management command does not work with Python ≥ 3.8 on
 Windows.

 === Steps to reproduce

 1. Open any Django project.
 2. Run `python manage.py runserver`.

 ==== Actual result

 {{{
 C:\Programs\Python38\python.exe C:/project/manage.py runserver
 2020-10-11 18:12:08,823 INFO  [django.utils.autoreload] Watching for file
 changes with StatReloader
 Exception in thread django-main-thread:
 Traceback (most recent call last):
   File "C:\Programs\Python38\lib\threading.py", line 932, in
 _bootstrap_inner
     self.run()
   File "C:\Programs\Python38\lib\threading.py", line 870, in run
     self._target(*self._args, **self._kwargs)
   File "C:\Programs\Python38\lib\site-
 packages\django\utils\autoreload.py", line 53, in wrapper
     fn(*args, **kwargs)
   File "C:\Programs\Python38\lib\site-
 packages\django\core\management\commands\runserver.py", line 110, in
 inner_run
     autoreload.raise_last_exception()
   File "C:\Programs\Python38\lib\site-
 packages\django\utils\autoreload.py", line 76, in raise_last_exception
     raise _exception[1]
   File "C:\Programs\Python38\lib\site-
 packages\django\core\management\__init__.py", line 357, in execute
     autoreload.check_errors(django.setup)()
   File "C:\Programs\Python38\lib\site-
 packages\django\utils\autoreload.py", line 53, in wrapper
     fn(*args, **kwargs)
   File "C:\Programs\Python38\lib\site-packages\django\__init__.py", line
 24, in setup
     apps.populate(settings.INSTALLED_APPS)
   File "C:\Programs\Python38\lib\site-packages\django\apps\registry.py",
 line 91, in populate
     app_config = AppConfig.create(entry)
   File "C:\Programs\Python38\lib\site-packages\django\apps\config.py",
 line 116, in create
     mod = import_module(mod_path)
   File "C:\Programs\Python38\lib\importlib\__init__.py", line 127, in
 import_module
     return _bootstrap._gcd_import(name[level:], package, level)
   File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
   File "<frozen importlib._bootstrap>", line 991, in _find_and_load
   File "<frozen importlib._bootstrap>", line 975, in
 _find_and_load_unlocked
   File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
   File "<frozen importlib._bootstrap_external>", line 783, in exec_module
   File "<frozen importlib._bootstrap>", line 219, in
 _call_with_frames_removed
   File "C:\Programs\Python38\lib\site-packages\channels\apps.py", line 6,
 in <module>
     import daphne.server
   File "C:\Programs\Python38\lib\site-packages\daphne\server.py", line 20,
 in <module>
     asyncioreactor.install(twisted_loop)
   File "C:\Programs\Python38\lib\site-
 packages\twisted\internet\asyncioreactor.py", line 320, in install
     reactor = AsyncioSelectorReactor(eventloop)
   File "C:\Programs\Python38\lib\site-
 packages\twisted\internet\asyncioreactor.py", line 69, in __init__
     super().__init__()
   File "C:\Programs\Python38\lib\site-packages\twisted\internet\base.py",
 line 571, in __init__
     self.installWaker()
   File "C:\Programs\Python38\lib\site-
 packages\twisted\internet\posixbase.py", line 286, in installWaker
     self.addReader(self.waker)
   File "C:\Programs\Python38\lib\site-
 packages\twisted\internet\asyncioreactor.py", line 151, in addReader
     self._asyncioEventloop.add_reader(fd, callWithLogger, reader,
   File "C:\Programs\Python38\lib\asyncio\events.py", line 501, in
 add_reader
     raise NotImplementedError
 NotImplementedError
 }}}

 ==== Expected result
 No errors.

 === Workaround
 Add the following code to the `manage.py` file:
 {{{
 #!python
 if sys.platform == 'win32' and sys.version_info >= (3, 8):
     import asyncio
 asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
 }}}

 === References
 - https://stackoverflow.com/questions/58908293/i-keep-getting-
 notimplementederror-error-when-starting-django-server

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32103>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/051.ac7d72baddbdca74806c4c65a64482c7%40djangoproject.com.

Reply via email to