zoukankan      html  css  js  c++  java
  • Django——ModuleNotFoundError: No module named 'asgiref.sync'

    Django+channels运行时报错

    Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x7f267151a840>
    Traceback (most recent call last):
      File "/root/ENVS/dj11.7/lib/python3.7/site-packages/django/utils/autoreload.py", line 228, in wrapper
        fn(*args, **kwargs)
      File "/root/ENVS/dj11.7/lib/python3.7/site-packages/django/core/management/commands/runserver.py", line 117, in inner_run
        autoreload.raise_last_exception()
      File "/root/ENVS/dj11.7/lib/python3.7/site-packages/django/utils/autoreload.py", line 251, in raise_last_exception
        six.reraise(*_exception)
      File "/root/ENVS/dj11.7/lib/python3.7/site-packages/django/utils/six.py", line 685, in reraise
        raise value.with_traceback(tb)
      File "/root/ENVS/dj11.7/lib/python3.7/site-packages/django/utils/autoreload.py", line 228, in wrapper
        fn(*args, **kwargs)
      File "/root/ENVS/dj11.7/lib/python3.7/site-packages/django/__init__.py", line 27, in setup
        apps.populate(settings.INSTALLED_APPS)
      File "/root/ENVS/dj11.7/lib/python3.7/site-packages/django/apps/registry.py", line 116, in populate
        app_config.ready()
      File "/root/ENVS/dj11.7/lib/python3.7/site-packages/channels/apps.py", line 20, in ready
        monkeypatch_django()
      File "/root/ENVS/dj11.7/lib/python3.7/site-packages/channels/hacks.py", line 10, in monkeypatch_django
        from .management.commands.runserver import Command as RunserverCommand
      File "/root/ENVS/dj11.7/lib/python3.7/site-packages/channels/management/commands/runserver.py", line 11, in <module>
        from channels.routing import get_default_application
      File "/root/ENVS/dj11.7/lib/python3.7/site-packages/channels/routing.py", line 9, in <module>
        from channels.http import AsgiHandler
      File "/root/ENVS/dj11.7/lib/python3.7/site-packages/channels/http.py", line 16, in <module>
        from asgiref.sync import async_to_sync, sync_to_async
    ModuleNotFoundError: No module named 'asgiref.sync'

    解决:

    pip install asgiref==2.1.1

    应该是默认的asgiref版本不对,需要手动指定版本

  • 相关阅读:
    微信小程序开发入门(六)
    JS计算日期加上指定天数得到新的日期
    Java中substring()
    List集合去除重复数据
    按钮倒计时
    jQuery中each方法
    Math三个函数
    jQuery表单提交
    jQuery 序列化表单数据
    正则取小数点后面几位
  • 原文地址:https://www.cnblogs.com/huang-yc/p/10048672.html
Copyright © 2011-2022 走看看