We Are Going To Discuss About cannot import name ‘MutableMapping’ from ‘collections’ . So lets Start this Python Article.
cannot import name ‘MutableMapping’ from ‘collections’
- How to solve cannot import name 'MutableMapping' from 'collections' [duplicate]
You need to import collection.abc
Here the link to doc>>> from collections import MutableMapping Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: cannot import name 'MutableMapping' from 'collections' (/usr/lib/python3.10/collections/__init__.py) >>> from collections.abc import MutableMapping
- cannot import name 'MutableMapping' from 'collections' [duplicate]
You need to import collection.abc
Here the link to doc>>> from collections import MutableMapping Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: cannot import name 'MutableMapping' from 'collections' (/usr/lib/python3.10/collections/__init__.py) >>> from collections.abc import MutableMapping
Solution 1
You need to import collection.abc
Here the link to doc
>>> from collections import MutableMapping
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name 'MutableMapping' from 'collections' (/usr/lib/python3.10/collections/__init__.py)
>>> from collections.abc import MutableMapping
Deprecated since version 3.3, will be removed in version 3.10: Moved Collections Abstract Base Classes to the collections.abc module. For backwards compatibility, they continue to be visible in this module through Python 3.9.
Original Author Nabil Of This Content
Solution 2
If you have more than one interpreter, use:
import sys
if sys.version_info[:2] >= (3, 8):
from collections.abc import MutableMapping
else:
from collections import MutableMapping
Original Author navylover Of This Content
Solution 3
The direct import has been deprecated since Python 3.3 and will stop working in Python 3.9. You need to import using
from collections.abc import MutableMapping
This is the deprication warning I got
DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3,and in 3.9 it will stop working
Original Author Kabilan Mohanraj Of This Content
Conclusion
So This is all About This Tutorial. Hope This Tutorial Helped You. Thank You.