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版本不对,需要手动指定版本

Django——ModuleNotFoundError: No module named 'asgiref.sync'

原文地址:https://www.cnblogs.com/huang-yc/p/10048672.html

时间: 2024-10-07 05:57:31

Django——ModuleNotFoundError: No module named 'asgiref.sync'的相关文章

centos7安装python3和Django后,ModuleNotFoundError: No module named &#39;_sqlite3&#39;

1.准备安装环境 yum groupinstall 'Development Tools' yum install zlib-devel bzip2-devel openssl-devel ncurses-devel 2.安装python3 去官网下载编译安装包或者直接执行以下命令下载 wget https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tar.xz 解压 tar -xvJf  Python-3.6.2.tar.xz 切换进入 cd

Django遇到问题:pip安装了django,但是还是提示ModuleNotFoundError: No module named &#39;django&#39;

原因django安装的包不在python的默认路径下. 方法: 1.查看python路径 2.找到pip安装的路径 3.加入PATHONPATH [[email protected] ~]# PYTHONPATH="/usr/local/lib/python3.6/site-packages"[[email protected] ~]# export PYTHONPATH Django遇到问题:pip安装了django,但是还是提示ModuleNotFoundError: No mod

ModuleNotFoundError: No module named &#39;django&#39;

1 .就在前天 我还能用python3 manage.py runserver 0.0.0.0:8000 启动Django  今天就突然报错了(心情极为复杂,你这也能信?) 2.打印python找包的路径和环境变量 print(sys.path) 3.执行pip3 install django  查看pip安装完包的路径 ,对比这张 图和上一张图路径完全不一样 (问题原因 , 找不到包 正常). 4.知道原因问题就很好处理了, 把这个包的路径加入到Python的环境变量中 # 打开这个文档 vi

Django数据迁移时提示 ModuleNotFoundError: No module named &#39;users&#39;

执行数据迁移时提示找不到对应的APP,错误如下: 这个错误主要是路径找不到引起的,只需在settings文件夹中添加app文件路径即可 sys.path.insert(0, os.path.join(BASE_DIR, 'apps')) Django数据迁移时提示 ModuleNotFoundError: No module named 'users' 原文地址:https://www.cnblogs.com/icewky/p/12364717.html

ModuleNotFoundError: No module named &#39;video_back.urls&#39;

新建Django项目时将settings,urls移除来时报错. 这是我所想要的项目结构  >>>  扁平结构. 将下面这个应用的名字删掉就可以了. ModuleNotFoundError: No module named 'video_back.urls' 原文地址:https://www.cnblogs.com/sumafan/p/10792451.html

解决scrapy fetch http://www.csdn.net ModuleNotFoundError No module named &#39;win32api&#39;

1.解决scrapy fetch http://www.csdn.netModuleNotFoundError No module named 'win32api' Python是没有自带访问windows系统API的库的,需要下载.库的名称叫pywin32,可以从网上直接下载. 以下链接地址可以下载:http://sourceforge.net/projects/pywin32/files%2Fpywin32/ (下载适合你的python版本) 解决scrapy fetch http://ww

你所不知道的 【ModuleNotFoundError: No module named &#39;&#39;; &#39;&#39; is not a package】

一.背景介绍 1. 工具目录结构 为了便于统一管理一些小工具,在本地创建了一个mytools的目录,子目录的结构如下: 2.python搜索路径 在环境变量中,增加了PYTHONPATH的设置,value为'e:\mytools\lib\python'. 二.问题描述 做好准备工作后,信心满满的运行了一把,结果却是从未见过的'ModuleNotFoundError: No module named 'addhosts.argument_exception'; 'addhosts' is not

python异常之ModuleNotFoundError: No module named &#39;test01inner02&#39;

当我们使用sys.path.append(args) 指令向程序中导入模块时其实本次append操作只是在内存中完成的,如果要永久性的添加需要修改环境变量. 我们发现当我们使用print(sys.path)后返回的是一个列表,其中包含当前文件所在项目的路径,还有python的默认加载库,添加只是暂时的. 错误调用: 目录结构: A.test0102.py文件 # coding = utf-8 def sing(): print("happay new year") B.init.py文

python解决导入自定义库失败: ModuleNotFoundError: No module named &#39;MyLib&#39;

python安装目录:...\python_3_6_1_64bit 新建文件:chenyeubai.pth,写入库所在的绝对路径E:\workSpace\my_code\learn\myLib 安装路径下的.pth文件会在运行时将文件中路径写入path python解决导入自定义库失败: ModuleNotFoundError: No module named 'MyLib' 原文地址:https://www.cnblogs.com/chenyuebai/p/8416706.html