python11报错cannot import name 'Container' from 'collections'
部署项目的时候报错:
1 | ImportError: cannot import name ‘Mapping‘ from ‘collections‘ |
修复的方法也很简单:
将如下代码:
1 | from collections import Mapping |
修改为:
1 | from collections.abc import Mapping |
重启项目,问题解决。
类似报错还有:
1 | ImportError: cannot import name 'Mapping' from 'collections' (/opt/python/lib/python3.11/collections/__init__.py) |
修改:
1 | from collections import Mapping |
为:
1 | from collections.abc import Mapping |
问题解决。