python3.11的版本,运行 django项目 报错AttributeError: module ‘collections‘ has no attribute ‘Iterator‘

python3.11的版本,运行 django项目 报错AttributeError: module ‘collections’ has no attribute ‘Iterator’

问题描述—运行 django项目 报错AttributeError: module ‘collections’ has no attribute ‘Iterator’

报错信息:

image.png

问题原因

Python 3.11中已经将collections.Iterable改为typing.Iterable,而Django 2.2和以前的版本中使用了collections.Iterator,因此无法兼容Python 3.11。

解决方法

为了解决这个问题,您需要升级到Django 3.2以上的版本,因为Django 3.2中已经对Python 3.11进行了兼容性修复。

您可以通过以下命令升级Django版本:

也可以使用3.2版本  pip install Django==3.2
pip install --upgrade django

image.png

image.png

或者如果您使用的是虚拟环境,可以在激活该环境后运行:

python -m pip install --upgrade django

python3.11 配置django3.2的版本就行了,4.几的版本会出现mysql版本跟不上问题。

问题解决

运行成功,编码问题解决

image.png

猜你喜欢

转载自blog.csdn.net/Deng872347348/article/details/130316702