67

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)

Taku
  • 31,927
  • 11
  • 74
  • 85
Setsuna
  • 2,081
  • 7
  • 32
  • 50

7 Answers7

99

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.

nacho_dh
  • 1,847
  • 3
  • 18
  • 27
42

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
srk
  • 566
  • 1
  • 4
  • 4
  • I'm also somewhat surprised to report that this works like a charm. +1 – Brionius Aug 30 '15 at 02:36
  • `pip` is awesome :P – Blairg23 Oct 23 '16 at 22:44
  • Accidentally installed `pip` using `sudo easy_install pip` with the version that ships with macOS Sierra. This solution appears to have resolved my predicament. Other information, if anybody else reads this or cares: `Python 2.7.10 (default, Jul 30 2016, 19:40:32) [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin` – unjankify Apr 03 '17 at 01:04
12

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
aralar
  • 3,022
  • 7
  • 29
  • 44
10

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

Community
  • 1
  • 1
t0r0X
  • 4,212
  • 1
  • 38
  • 34
  • 1
    Mind that you might have various Python versions installed. Then you need to write the exact version in front, like `python3.7 -m uninstall pip setuptools` if you also have a `python3.6` installed which would dominate the `python3.7` if the environmental variables are set like this, see [pip/python: normal site-packages is not writeable](https://stackoverflow.com/questions/59997065/pip-python-normal-site-packages-is-not-writeable/65290638#65290638) – questionto42 Dec 14 '20 at 15:13
1

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.

jaminyah
  • 11
  • 2
0

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

nasaplays
  • 5
  • 3
0

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"