Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cannot import name 'MutableMapping' from 'collections' [duplicate]

I'm getting the following error:

  File "/home/ron/rzg2l_bsp_v1.3/poky/bitbake/lib/bb/compat.py", line 7, in <module>
    from collections import MutableMapping, KeysView, ValuesView, ItemsView, OrderedDict
ImportError: cannot import name 'MutableMapping' from 'collections' (/usr/lib/python3.10/collections/__init__.py)

and Googling revealed that flask has to be >=2.0, so I did

$ sudo pacman -Syu python-flask

which installed version (2.0.2-3)

which did not resolve the issue. Further searching revealed that babelfish needs to be upgraded too, so I did:

$ python3.10 -m pip install babelfish -U

which showed me:

Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: babelfish in /home/ron/.local/lib/python3.10/site-packages (0.6.0)
Collecting babelfish
  Using cached babelfish-0.6.0-py3-none-any.whl (93 kB)
  Downloading babelfish-0.5.5.tar.gz (90 kB)
     |████████████████████████████████| 90 kB 406 kB/s

but I'm still getting the same error. Can anyone tell what else I'm missing?

like image 553
stdcerr Avatar asked Aug 30 '25 15:08

stdcerr


1 Answers

You need to import collections.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.

Ref. https://docs.python.org/3.9/library/collections.html

like image 171
Nabil Avatar answered Sep 02 '25 16:09

Nabil