I’ve installed python-pip. It was worked before but suddenly pip throwing error!
I can’t able to make any oparation using pip…
here is the error below
[muhammadabir@muhammadabir-pc ~]$ pip -V
Traceback (most recent call last):
File "/usr/bin/pip", line 5, in <module>
from pip._internal.cli.main import main
File "/usr/lib/python3.10/site-packages/pip/_internal/cli/main.py", line 9, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "/usr/lib/python3.10/site-packages/pip/_internal/cli/autocompletion.py", line 10, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "/usr/lib/python3.10/site-packages/pip/_internal/cli/main_parser.py", line 8, in <module>
from pip._internal.cli import cmdoptions
File "/usr/lib/python3.10/site-packages/pip/_internal/cli/cmdoptions.py", line 22, in <module>
from pip._vendor.packaging.utils import canonicalize_name
File "/usr/lib/python3.10/site-packages/pip/_vendor/__init__.py", line 61, in <module>
File "/usr/lib/python3.10/site-packages/pip/_vendor/__init__.py", line 33, in vendored
__import__(modulename, globals(), locals(), level=0)
File "/usr/lib/python3.10/site-packages/cachecontrol/__init__.py", line 9, in <module>
from .wrapper import CacheControl
File "/usr/lib/python3.10/site-packages/cachecontrol/wrapper.py", line 1, in <module>
from .adapter import CacheControlAdapter
File "/usr/lib/python3.10/site-packages/cachecontrol/adapter.py", line 5, in <module>
from requests.adapters import HTTPAdapter
File "/home/muhammadabir/.local/lib/python3.10/site-packages/requests/__init__.py", line 63, in <module>
from . import utils
File "/home/muhammadabir/.local/lib/python3.10/site-packages/requests/utils.py", line 27, in <module>
from .cookies import RequestsCookieJar, cookiejar_from_dict
File "/home/muhammadabir/.local/lib/python3.10/site-packages/requests/cookies.py", line 172, in <module>
class RequestsCookieJar(cookielib.CookieJar, collections.MutableMapping):
AttributeError: module 'collections' has no attribute 'MutableMapping'
Well, no… If a command does not work with sudo that doesn’t mean you should just run it with sudo.
There are certain commands you should never, ever, run with sudo (I call them: sudon't).
For example, a GUI text editor won’t let you edit a root owned file unless you run it with sudo, but you know that you should never do that – never run GUI programs with sudo.
In the case of pip, on Arch Linux (and EndeavourOS) you certainly shouldn’t run it with sudo, ever. Without sudopip won’t let you globally install Python modules, and that’s the whole point – you shouldn’t be doing that. Instead, you should be using pacman (ALPM) to install all global packages, including Python modules. This way, they won’t be invisible to the ALPM.
TL;DR: don’t use sudo when you shouldn’t be using sudo, even if the command does not work without sudo. Specifically, don’t use sudo with GUI programs and third party package managers like pip, npm, and gem.
That is golden advice Pudge. So obvious, but so easily overlooked. The problem with trying sudo first, is if it works you would not have known if it was going to work without sudo. And, then as Dalto said with sudo…
which you also would not have known about until it came time to update. I fell into this trap once and it became a nightmare updating and fixing anything that was dependent on pip .