How do I reinstall pip and its packages when pip doesn't work?

When I tried to install a google pip package it broke my pip installation and now I can't use pip to install or remove anything. I know I should have used a virtualenv but I already didn't.

If I just delete the site-packages folder on linux at

/usr/lib/python3.9/site-packages
/usr/lib/python3.10/site-packages

to reinstall everything will that fix it? Or will this just break things further?

There's this previous post, but it's 10 years old and they just tell the user to use pip to uninstall things, which won't work in my case.

For what it's worth, this is the error, but I don't think there's any easy fix for this other than removing and reinstalling everything.

ERROR: Exception:
Traceback (most recent call last): File "/usr/lib/python3.10/site-packages/pip/_internal/cli/base_command.py", line 223, in _main status = self.run(options, args) File "/usr/lib/python3.10/site-packages/pip/_internal/cli/req_command.py", line 180, in wrapper return func(self, options, args) File "/usr/lib/python3.10/site-packages/pip/_internal/commands/install.py", line 305, in run resolver = self.make_resolver( File "/usr/lib/python3.10/site-packages/pip/_internal/cli/req_command.py", line 295, in make_resolver import pip._internal.resolution.resolvelib.resolver File "/usr/lib/python3.10/site-packages/pip/_internal/resolution/resolvelib/resolver.py", line 25, in <module> from .factory import Factory File "/usr/lib/python3.10/site-packages/pip/_internal/resolution/resolvelib/factory.py", line 33, in <module> from .found_candidates import FoundCandidates File "/usr/lib/python3.10/site-packages/pip/_internal/resolution/resolvelib/found_candidates.py", line 13, in <module> from pip._vendor.six.moves import collections_abc # type: ignore
ImportError: cannot import name 'collections_abc' from 'six.moves' (unknown location)

Thanks for your time!

1 Answer

You can simply reinstall it via your package manager.

From your selected flair I can see you use arch.

To remove pip and all of its config files run:

sudo pacman -Rns python-pip

Afterwards reinstall it via:

sudo pacman -S python-pip
3

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like