52

I have installed a few versions on my MacBook for different projects and have only now realized what a mistake that was. I have used homebrew to install it, installed it via python's website (Python 2.7.8 Mac OS X 64-bit/32-bit x86-64/i386 Installer (for Mac OS X 10.6 and later [2])) and other ways I may not remember. I am running 10.9.4 OS X.

I am wondering how I can find the location of all python installations on my computer and delete everything and packages that depend on them except the native one. I'd like to essentially start from scratch without reinstalling my OS.

Also, I am wondering if I can apply the same method to find all pip related files.

Update:

which -a python gives me all the paths to each executable python. Is it normal to have multiple ones?

╭─[email protected] ~
╰─➤  which -a python
/usr/bin/python
/usr/bin/python
/usr/bin/python
/usr/bin/python
/usr/bin/python
/usr/bin//python
/usr/bin//python
/usr/bin/python
5
  • you can start by removing any Python Frameworks in /Library/Frameworks and any User Library (like ~/Library/Frameworks). The system one is in /System/Library/Frameworks. Commented Sep 15, 2014 at 16:53
  • @BradAllred what installation is in usr/bin/ and which is in usr/local/bin? Commented Sep 15, 2014 at 22:09
  • those aren't installed as part of the system if that is what you are asking. your homebrew install would be one or both of those. Commented Sep 15, 2014 at 22:58
  • Possible duplicate of What version of Python is on my Mac? Commented Nov 12, 2017 at 20:55
  • If you are coming here with Monterey 12.3 (or newer, I guess, as I can't see the future). There is no longer a system python installation. Commented Mar 29, 2022 at 15:13

2 Answers 2

50

It's normal to have many python binaries. You can see which is which in /usr/bin with this command:

$ ls -l /usr/bin/python*

You will see several links to different places. The native python is that one, which is in the /System/Library/Frameworks/Python.framework/Versions/2.7/bin/. Note that for OSX 10.9 (and for everything at least until 10.13) this is the python2, not python3. So you can safely remove all the other versions.

What are the other versions which you may have?

  • Something downloaded from the official site python.org. It is located in /Library/Frameworks/Python.framework/Versions/. You can remove whatever in this folder you do not want. Removing the whole folder will completely remove Python including the original system version.
  • Anaconda distribution is by default located in /Users/your_user/anaconda3/, but of course you may put in the other place. But if it contains anaconda in the path – it's Anaconda distribution. You may remove this folder.
  • Either homebrew or port versions are in /opt/local/bin/. See the link destination with $ ls -l /opt/local/bin/python*. The best way of removing this is to use built-in commands like uninstall.
  • Some packages might be in ~/Library/Python/ - that's from pip. You may safely remove the entire content of this folder in order to have a "clean" python.
  • Finally, after you removed all the other versions, do not forget to remove the broken links to binaries, if there are still any.

See also this answer.

5
  • Thanks @Yury Kirienko , I was having this problem and this helped Commented Sep 4, 2018 at 18:49
  • Homebrew actually installs symlinks in /usr/local/bin/. Maybe that's a change, but there I just found 4 different python versions... Commented Apr 6, 2023 at 9:23
  • Using sudo uninstall python311 tells me it will break dependencies... am I about to regret following these instructions?
    – John Smith
    Commented Nov 4, 2023 at 2:16
  • Um, you should have made it clearer that deleting /Library/Frameworks/Python.framework/Versions/ will remove the original system python too!
    – John Smith
    Commented Nov 4, 2023 at 2:19
  • Besides which, these instructions appear incomplete. "remove the broken links to binaries"? I've stared hard at my command line and yelled, "Broken links to binaries, BEGONE!" three times now, and it's still looking for the version of python I removed. There is apparently more detail that is missing.
    – John Smith
    Commented Nov 4, 2023 at 2:30
8

you can start by removing any Python Frameworks in /Library/Frameworks and any User Library (like ~/Library/Frameworks). The system one is in /System/Library/Frameworks.

homebrew and macports install under /usr somewhere IIRC. not sure of other places to look, but you should be able to grep for "Python" to find them all.

be aware, if you have installed other software via homebrew that is dependent on Python, you will break it. you may be able to fix it with symbolic links to the system python, however, some software requires Python 3. as of 10.9 the system has Python 2.3-2.7 only.

2
  • 2
    ls -la /usr/bin/pyt* should show you where all python installations are located, since /usr/bin contains just sym links... Commented Dec 4, 2015 at 11:08
  • macports installs your python into the /opt/local/bin/python folder
    – Simon
    Commented Jan 24, 2017 at 11:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.