How to uninstall pip on OSX?

Question:

I ran the following commands:

easy_install pip
sudo pip install setuptools --no-use-wheel --upgrade

How do I reverse the two commands to get my python back to its original state in OSX? (removing pip as part of it)

Asked By: Setsuna

||

Answers:

The first thing you should try is:

sudo pip uninstall pip

On many environments that doesn’t work. So given the lack of info on that problem, I ended up removing pip manually from /usr/local/bin.

Answered By: nacho_dh

In order to completely remove pip, I believe you have to delete its files from all Python versions on your computer. For me, they are here:

cd /Library/Frameworks/Python.framework/Versions/Current/bin/
cd /Library/Frameworks/Python.framework/Versions/3.3/bin/

You may need to remove the files or the directories located at these file-paths (and more, depending on the number of versions of Python you have installed).

Edit: to find all versions of pip on your machine, use:
find / -name pip 2>/dev/null, which starts at its highest level (hence the /) and hides all error messages (that’s what 2>/dev/null does). This is my output:

$ find / -name pip 2>/dev/null
/Library/Frameworks/Python.framework/Versions/2.7/bin/pip
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip
/Library/Frameworks/Python.framework/Versions/3.3/bin/pip
/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages/pip
/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/pip
/Library/Frameworks/Python.framework/Versions/7.1/bin/pip
/Library/Frameworks/Python.framework/Versions/7.1/lib/python2.7/site-packages/pip-1.4.1-py2.7.egg/pip
Answered By: aralar

In my case I ran the following command and it worked (not that I was expecting it to):

sudo pip uninstall pip

Which resulted in:

Uninstalling pip-6.1.1:
  /Library/Python/2.7/site-packages/pip-6.1.1.dist-info/DESCRIPTION.rst
  /Library/Python/2.7/site-packages/pip-6.1.1.dist-info/METADATA
  /Library/Python/2.7/site-packages/pip-6.1.1.dist-info/RECORD
  <and all the other stuff>
  ...

  /usr/local/bin/pip
  /usr/local/bin/pip2
  /usr/local/bin/pip2.7
Proceed (y/n)? y
  Successfully uninstalled pip-6.1.1
Answered By: srk

Aditionally to the answer from @srk, you should uninstall package setuptools:

python -m pip uninstall pip setuptools

If you want to uninstall all other packages first, this answer has some hints: https://stackoverflow.com/a/11250821/265954

Note: before you use the commands from that answer, please carefully read the comments about side effects and how to avoid uninstalling pip and setuptools too early. E.g. pip freeze | grep -v "^-e" | grep -v "^(setuptools|pip)" | xargs pip uninstall -y

Answered By: t0r0X

Since pip is a package,
pip uninstall pip
Will do it.
EDIT: If that does not work, try sudo -H pip uninstall pip.

Answered By: nasaplays

On macOS Big Sur Version 11.0.1

$ which pip
output: /usr/local/bin/pip
$ cd /usr/local/bin

There I found pip, pip2, pip2.7

$ sudo rm -r pip # for each version to remove

Somehow the installation with easy_install was corrupted.

Answered By: jaminyah

First see the path of the python site-packages files by running this python code

import os 
import inspect 
print(os.path.dirname(inspect.getfile(inspect))+"/site-packages") 

a path will be printed, take it and add it as a parameter to your pip command

pip install package_name -t "the printed path"

Eg: pip install pandas -t "the printed path"

Answered By: Viraj Rathod
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.