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