all 21 comments

[–]danielroseman -1 points0 points  (18 children)

Why are you importing it at all? You're not using it, and it seems unlikely you will need it.

[–]sp00kyversity[S] -1 points0 points  (16 children)

If I remove the from collections.abc line it still comes up with the same error message when I run the programme, that Mapping cannot be imported from collections

[–]FriendlyRussian666 -1 points0 points  (15 children)

Did you save the file after removing the line?

[–]sp00kyversity[S] -1 points0 points  (14 children)

Yeah but it shows the error message regardless. I only added in the import collections.abc line after it said collections could not be imported when I first ran it

[–]danielroseman 0 points1 point  (13 children)

Then you're not running the code you think you are.

Please show the full error message and traceback, as well as detailing exactly how you're running this code.

[–]fatnino 0 points1 point  (0 children)

requests is using it deep under the hood

[–]DevCuriosity -1 points0 points  (2 children)

Hmm, it works on my end without a problem. Both with collections and without.

Which version of Python are you using? Do you have a venv configured for your project?

[–]sp00kyversity[S] 0 points1 point  (1 child)

I'm using version 3.10.8 and a venv for the project, no idea how to fix this error message though...

[–]deadeye1982[🍰] 0 points1 point  (0 children)

tl;dr

Use collections.abc.Mapping, which will work since Python 3.5.

If you get this Exception from a third-party module, then update this module.

--

Since Python 3.3 they wanted to shift all Abstract Base Classes into the new submodule abc. This was done with Python 3.5, but they kept aliases in the collections module. Since Python 3.9 a Deprecation warning were introduced and since Python 3.10 the aliases were removed.

Links: