4

This issue is coming right now. why i don't know. But i was not facing this issue before 2 / 3 days. This error is coming, when my 'import request' starts running. I have tried every single solution on internet but nothing seems to worked.

"C:\Program Files\Python310\python.exe"
"E:/IT Vedant/Rough Work/1mg.py"
Traceback (most recent call last):
  File "E:\IT Vedant\Rough Work\1mg.py", line 2, in <module>
    import requests
  File "C:\Program Files\Python310\lib\site-packages\requests\__init__.py", line 58, in <module>
    from . import utils
  File "C:\Program Files\Python310\lib\site-packages\requests\utils.py", line 26, in <module>
    from .compat import parse_http_list as _parse_list_header
  File "C:\Program Files\Python310\lib\site-packages\requests\compat.py", line 7, in <module>
    from .packages import chardet
  File "C:\Program Files\Python310\lib\site-packages\requests\packages\__init__.py", line 3, in <module>
    from . import urllib3
  File "C:\Program Files\Python310\lib\site-packages\requests\packages\urllib3\__init__.py", line 10, in <module>
    from .connectionpool import (
  File "C:\Program Files\Python310\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 38, in <module>
    from .response import HTTPResponse
  File "C:\Program Files\Python310\lib\site-packages\requests\packages\urllib3\response.py", line 5, in <module>
    from ._collections import HTTPHeaderDict
  File "C:\Program Files\Python310\lib\site-packages\requests\packages\urllib3\_collections.py", line 1, in <module>
    from collections import Mapping, MutableMapping
ImportError: cannot import name 'Mapping' from 'collections' (C:\Program Files\Python310\lib\collections\__init__.py)

Process finished with exit code 1
1
  • Please provide enough code so others can better understand or reproduce the problem. Commented May 9, 2022 at 6:31

3 Answers 3

4

You are using python 3.10

try changing from from collections import Mapping to from collections.abc import Mapping

Sign up to request clarification or add additional context in comments.

3 Comments

I have done this already. still not working
then pleas post your code and what you have tried aswell as the entrire stack trace
check here is the full error
4

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

Comments

3

in You python 3.10 go to this link

C:\Program Files\Python310\lib\collections\

and open file __init__.py

in this file change:

from collections import Mapping

to

from collections.abc import Mapping

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.