-1

When I run project on my local machine gives this error:

ImportError: cannot import name 'Mapping' from 'collections' (C:\Users\User\AppData\Local\Programs\Python\Python310\lib\collections_init_.py)

any suggestion?

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245

2 Answers2

-1

because there is no object called Mapping in collections
check the Docs

this object exists in a different module To import that
from _collections_abc import Mapping

Ayman
  • 363
  • 2
  • 9
-1

My C:\Program Files\Python310\lib\collections\__init__.py from section didn't seem to have the required entries.

To resolve this, I added the following to that file:

from collections.abc import Mapping
from collections.abc import MutableMapping
from collections.abc import Sequence

Additionally my project .py file still had the legacy code line import collections which I replaced with the new code line from collections.abc import Mapping

rgbhex00
  • 97
  • 3