python 3.7.3
django 2.2
...按照项目 requirements.txt 安装的环境
在访问登陆接口时,抛出异常—— sync_to_async for converting generators to async generators
项目环境的一个依赖包 asgiref 版本不一致。原项目的 asgiref 为 3.3.1,(项目在四个月之前开始开发,当时的asgiref==3.3.1),而现在从git拉下项目,asgiref 为 3.3.2,
可能更新了依赖包,因此报出该异步错误。
将asgiref 重新安装 为 3.3.1
$ pip list|grep asgi
asgiref 3.3.2
$ pip install asgiref==3.3.1
还有一个可能的原因,之前的本机环境使用的是 django3.7.1,卸载时没有卸载完全,还有部分最新的依赖包没有移除。
https://ask.csdn.net/questions/1172080
【django】报错-sync_to_async for converting generators to async generators
原文:https://www.cnblogs.com/bigorangecc/p/14626305.html