python11报错cannot import name 'Container' from 'collections'

部署项目的时候报错:

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

问题解决。

本文为原创文章,转载请注明出处。

原文链接:https://850406.xyz/post/python11报错cannot-import-name-container-from-collections

评论(0)

还没有评论,来抢沙发吧~

验证码