How to find all python installations on mac os x and uninstall all but the native OS X installation

2024/11/19 9:34:40

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
Answer

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.

https://en.xdnf.cn/q/26460.html

Related Q&A

Who runs the callback when using apply_async method of a multiprocessing pool?

Im trying to understand a little bit of whats going on behind the scenes when using the apply_sync method of a multiprocessing pool. Who runs the callback method? Is it the main process that called ap…

Difference between hash() and id()

I have two user-defined objects, say a and b. Both these objects have the same hash values. However, the id(a) and id(b) are unequal.Moreover, >>> a is b False >>> a == b TrueFrom th…

get class name for empty queryset in django

I have empty queryset of model Studentstudents = Students.objects.all()If the above queryset is empty, then how can i get the model(class name)?How can i get the model name for empty queryset?EDIT:Ho…

`Sudo pip install matplotlib` fails to find freetype headers. [OS X Mavericks / 10.9] [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.This question does not appear to be about a specific programming problem, a software algorithm, or s…

Parallel processing from a command queue on Linux (bash, python, ruby... whatever)

I have a list/queue of 200 commands that I need to run in a shell on a Linux server. I only want to have a maximum of 10 processes running (from the queue) at once. Some processes will take a few secon…

How do I select and store columns greater than a number in pandas? [duplicate]

This question already has answers here:How do I select rows from a DataFrame based on column values?(17 answers)Closed 28 days ago.I have a pandas DataFrame with a column of integers. I want the rows …

Plotting transparent histogram with non transparent edge

I am plotting a histogram, and I have three datasets which I want to plot together, each one with different colours and linetype (dashed, dotted, etc). I am also giving some transparency, in order to s…

Cross-platform desktop notifier in Python

I am looking for Growl-like, Windows balloon-tip-like notifications library in Python. Imagine writing code like:>>> import desktopnotifier as dn >>> dn.notify(Title, Long description…

set object is not JSON serializable [duplicate]

This question already has answers here:How to JSON serialize sets? [duplicate](12 answers)Closed 9 years ago.When I try to run the following code:import jsond = {testing: {1, 2, 3}} json_string = json…

Python Sqlite3: INSERT INTO table VALUE(dictionary goes here)

I would like to use a dictionary to insert values into a table, how would I do this? import sqlite3db = sqlite3.connect(local.db) cur = db.cursor()cur.execute(DROP TABLE IF EXISTS Media)cur.execute(CR…