为什么:
from channels.asgi import get_channel_layer结果如下:
from channels.asgi import get_channel_layer
ImportError: No module named asgi我使用的是Django (1.9)和python(3.4)。而且,在pycharm中编辑时,我看到IDE为我提供了快速提示。
发布于 2019-05-22 18:51:23
我能够修复这个问题;如果您使用的是通道2,那么通道层与旧版本有很大的不同。
我建议您尝试以下操作:
settings.py上配置了通道层:CHANNEL_LAYERS ={“默认”:{“后端”:"channels_redis.core.RedisChannelLayer",“配置”:{“主机”:(“redis服务器名称”,6379),}
如果使用redis,希望您已经安装了redis。
asgi.py文件:从channels.layers导入get_channel_layer channel_layer = get_channel_layer()
您可以查看this解决方案。
发布于 2017-07-17 19:08:04
确保你已经安装了它,并仔细检查你已经激活了virtualenv。
pip install -U asgi_redis发布于 2016-03-29 05:29:32
使用
pip show channels来查看包的版本。
直到0.9版本,channels.asgi才出现:
https://github.com/andrewgodwin/channels/tree/0.8/channels https://github.com/andrewgodwin/channels/tree/0.9/channels
https://stackoverflow.com/questions/36270729
复制相似问题