I work on python 3.10
i face error and i can't solve it .
this error display when try to install new package or
using any pip
related command
python 3.10 already installed but can't add New Package using pip
this error as below got it from command prompt
C:\Program Files\Python310>pip list
Traceback (most recent call last):
File "C:\Program Files\Python310\lib\runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Program Files\Python310\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "C:\Program Files\Python310\Scripts\pip.exe\__main__.py", line 4, in <module>
File "C:\Users\sa\AppData\Roaming\Python\Python310\site-packages\pip\__init__.py", line 21, in <module>
from pip._vendor.urllib3.exceptions import DependencyWarning
File "C:\Users\sa\AppData\Roaming\Python\Python310\site-packages\pip\_vendor\urllib3\__init__.py", line 8, in <module>
from .connectionpool import (
File "C:\Users\sa\AppData\Roaming\Python\Python310\site-packages\pip\_vendor\urllib3\connectionpool.py", line 29, in <module>
from .connection import (
File "C:\Users\sa\AppData\Roaming\Python\Python310\site-packages\pip\_vendor\urllib3\connection.py", line 39, in <module>
from .util.ssl_ import (
File "C:\Users\sa\AppData\Roaming\Python\Python310\site-packages\pip\_vendor\urllib3\util\__init__.py", line 3, in <module>
from .connection import is_connection_dropped
File "C:\Users\sa\AppData\Roaming\Python\Python310\site-packages\pip\_vendor\urllib3\util\connection.py", line 3, in <module>
from .wait import wait_for_read
File "C:\Users\sa\AppData\Roaming\Python\Python310\site-packages\pip\_vendor\urllib3\util\wait.py", line 1, in <module>
from .selectors import (
File "C:\Users\sa\AppData\Roaming\Python\Python310\site-packages\pip\_vendor\urllib3\util\selectors.py", line 14, in <module>
from collections import namedtuple, Mapping
ImportError: cannot import name 'Mapping' from 'collections' (C:\Program Files\Python310\lib\collections\__init__.py)
so what i do to solve issue please ?
Last Updated Post
I delete folder urllib3 from path and execute command below to reinstall again .
but i get error as
C:\Users\sa\AppData\Roaming\Python\Python310\site-packages\pip\_vendor>pip install -U urllib3
Traceback (most recent call last):
File "C:\Program Files\Python310\lib\runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Program Files\Python310\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "C:\Program Files\Python310\Scripts\pip.exe\__main__.py", line 4, in <module>
File "C:\Users\sa\AppData\Roaming\Python\Python310\site-packages\pip\__init__.py", line 21, in <module>
from pip._vendor.urllib3.exceptions import DependencyWarning
ModuleNotFoundError: No module named 'pip._vendor.urllib3'
this is collections init.py file
https://pastebin.com/ADc9dV3b
so what i modify or on which place i will modify
CodePudding user response:
From Python 3.3 to 3.9, import Mapping
from collections
raised a DeprecationWarning
:
DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.10 it will stop working
Since Python 3.10, it doesn't work anymore. It looks like you are using an old version of urllib3
because the selector.py
file exists only on versions 1.20, 1.21 and 1.22. The current version is 1.26.
Upgrade urllib3
should solve the problem:
[...]# pip install -U urllib3
Update
Maybe you can remove manually the urllib3-X.Y.Z.dist-info
and urllib3
folders in C:\Users\sa\AppData\Roaming\Python\Python310\site-packages\pip\_vendor\
. After that reinstall urllib3
.
CodePudding user response:
Try editing the file
(C:\Program Files\Python310\lib\collections_init_.py )
and add to the import
from collections.abc import Mapping
Just add to collections (.abc) To get collections.abc