David Göransson
David Göransson

Reputation: 120

How to uninstall corrupt pip

I did a pip operation and got a suggestion from pip to upgrade:

You are using pip version 9.0.1, however version 9.0.3 is available.

You should consider upgrading via the 'pip install --upgrade pip' command.

Unfortunately I upgraded using sudo, even though I'm not convinced it is what actually caused my problems: sudo pip install --upgrade pip

Now whatever I try, pip complains about me not using pip 9.0.1:

pip
Traceback (most recent call last):
  File "/usr/local/opt/python/libexec/bin/pip", line 6, in <module>
    from pkg_resources import load_entry_point
  File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 3019, in <module>
    @_call_aside
  File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 3003, in _call_aside
    f(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 3032, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 657, in _build_master
    return cls._build_from_requirements(__requires__)
  File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 670, in _build_from_requirements
    dists = ws.resolve(reqs, Environment())
  File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 849, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'pip==9.0.1' distribution was not found and is required by the application

I want to either downgrade or reinstall, but all suggestions I find suggest doing pip uninstall pip or similar and that is not really an option at this point.

Any suggestions?

Upvotes: 2

Views: 5862

Answers (4)

Hanzla Habib
Hanzla Habib

Reputation: 3703

I was able to uninstall it, by installing python3.6 and then used this command

pip3 uninstall pip

if you CD into /usr/bin and find out pip directory, by that you will be able to identify different versions of pip on your system

enter image description here

posting this in a hope, in future may someone find this helpful for uninstalling corrupt verison of pip

Upvotes: 0

Albaro Pereyra Work
Albaro Pereyra Work

Reputation: 1

This worked for me:

curl -O https://bootstrap.pypa.io/get-pip.py
python get-pip.py --user

Then had to add the following to ~/.bashrc or ~/.zshrc :)

export PATH=~/.local/bin:$PATH

Type either

source ~/.bashrc

or

source ~/.zshrc

Then test it by running:

pip

The instructions were listed here: https://docs.aws.amazon.com/cli/latest/userguide/install-linux.html#install-linux-pip

Upvotes: 0

Roushan
Roushan

Reputation: 4420

For uninstalling pip you can use on debian

sudo apt remove python-pip --purge

And you can install it by

for python 2.7

sudo apt install python2-pip 

for python 3.x

sudo apt install python3-pip 

I suggest you to use virtualenv by this you can create fresh env and and install the dependencies that required and easy to delete also.

Upvotes: 0

Guybrush
Guybrush

Reputation: 2780

Consider having a look at the permissions defined for /usr/local/lib/python2.7/pip. Probably this directory is not readable, and consequently, Python cannot find pip distribution.

Upvotes: 2

Related Questions