Conchylicultor/DeepQA

ImportError: No module named 'asgiref.sync'

mihkhub opened this issue ยท 7 comments

When I build deepqa:latest image, from the root directory:

docker build -t deepqa:latest .

get error:

 ---> Running in 76634673f149
Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.5/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.5/site-packages/django/core/management/__init__.py", line 347, in execute
    django.setup()
  File "/usr/local/lib/python3.5/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/usr/local/lib/python3.5/site-packages/django/apps/registry.py", line 120, in populate
    app_config.ready()
  File "/usr/local/lib/python3.5/site-packages/channels/apps.py", line 17, in ready
    monkeypatch_django()
  File "/usr/local/lib/python3.5/site-packages/channels/hacks.py", line 10, in monkeypatch_django
    from .management.commands.runserver import Command as RunserverCommand
  File "/usr/local/lib/python3.5/site-packages/channels/management/commands/runserver.py", line 12, in <module>
    from channels.routing import get_default_application
  File "/usr/local/lib/python3.5/site-packages/channels/routing.py", line 9, in <module>
    from channels.http import AsgiHandler
  File "/usr/local/lib/python3.5/site-packages/channels/http.py", line 17, in <module>
    from asgiref.sync import async_to_sync, sync_to_async
ImportError: No module named 'asgiref.sync'
The command '/bin/sh -c python3 manage.py makemigrations' returned a non-zero code: 1

your channel version is latest so install the latest version of asgiref

pip install asgiref==2.2.0

I have installed latest version of channels and asgiref, but still I am getting that error.

I encountered the same problem.
raceback (most recent call last):
File "manage.py", line 22, in
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.5/site-packages/django/core/management/init.py", line 371, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.5/site-packages/django/core/management/init.py", line 347, in execute
django.setup()
File "/usr/local/lib/python3.5/site-packages/django/init.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/usr/local/lib/python3.5/site-packages/django/apps/registry.py", line 120, in populate
app_config.ready()
File "/usr/local/lib/python3.5/site-packages/channels/apps.py", line 17, in ready
monkeypatch_django()
File "/usr/local/lib/python3.5/site-packages/channels/hacks.py", line 10, in monkeypatch_django
from .management.commands.runserver import Command as RunserverCommand
File "/usr/local/lib/python3.5/site-packages/channels/management/commands/runserver.py", line 11, in
from channels.routing import get_default_application
File "/usr/local/lib/python3.5/site-packages/channels/routing.py", line 9, in
from channels.http import AsgiHandler
File "/usr/local/lib/python3.5/site-packages/channels/http.py", line 16, in
from asgiref.sync import async_to_sync, sync_to_async
ImportError: No module named 'asgiref.sync'
The command '/bin/sh -c python3 manage.py makemigrations' returned a non-zero code: 1

Add asgiref in the dependencies of Dockerfile
RUN
python3 -m pip install -U nltk
tqdm
django
asgi_redis
asgiref==2.2.0
channels &&
python3 -m nltk.downloader punkt

The problem fixed.

try to uninstall asgiref from your pyp packages and reinstall it again, it helped me. Works fine.

A year later worked for me :)

upgrade asgiref