What is the safest way to removing Python framework files that are located in different place than Brew installs
Asked Answered
R

1

55

I want to remove a Python installed in location that brew complains about, when I run brew doctor

Warning: Python is installed at /Library/Frameworks/Python.framework

What is the best way?

Here are more details / research:

The message from the brew git website:

Important: If you choose to install a Python which isn't either of these two (system Python or brewed Python), the Homebrew team can only provide limited support.

I want to make sure I am not missing anything before I remove the extra python libary. Specifically, I want to remove the entire Python.framework, those files located here. /Library/Frameworks/Python.framework/

I have Python 2.7.5 installed natively with Mavericks that I'll use instead - located in the path below. (The difference being -- I believe -- that its put in the root /System folder instead of the root /Library folder.) The good, native location is here: /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python

and I already installed python 3.x with brew install python3, which put it here:

==> Summary
    /usr/local/Cellar/python3/3.4.0  : 5076 files, 85M, built in 112 seconds

Can I just delete these files or are their consequences (beyond having to relink)? /Library/Frameworks/Python.framework/

Here are steps to remove python from a stackoverflow question in 2010 and a similar question here

Is that approach still sound? Is there anything I should be aware of?

Reconnoiter answered 1/4, 2014 at 0:11 Comment(1)
I had the native python on Mac OS, without removing which I installed python using brew and it created new symlinks and updated the hash for python too, works like a charm. If one isn't worried a lot about removing the older binaries, there isn't a necessity to remove them at all.Genteelism
R
73

I'll self-answer. I went through steps and it's straight forward. Pycharms (the IDE I'm use) automatically found the new libraries too. Here are the steps I followed to remove the extra Python libraries on Mavericks that were not native to it and not installed by brew.

Step 1: The native Python 2.7.x version lives here /System/Library/Frameworks/Python.framework/Versions/2.7 (or 2.6, etc), so you can remove any Python that got installed elsewhere.

sudo rm -rf /System/Library/Frameworks/Python.framework/

Or, according to this article, you should brew install both python 2.7 and python 3.x, and avoid using system python in Mavericks.

Step 2: Remove python in Applications directory (the one where all your apps are).

cd into folder /Applications and ls | grep Python to see what have.

Then remove: sudo rm -rf "Python 3.3"

Step 3:

>>> brew prune

sample output:

Pruned 0 dead formula Pruned 46 symbolic links from /usr/local

Step 4: Run steps recommended by brew doctor

sudo brew link python3

Sample output

Linking /usr/local/Cellar/python3/3.4.0... 19 symlinks created

Reconnoiter answered 2/4, 2014 at 3:6 Comment(5)
You also need to find and delete any broken symlinks in /usr/local/bin that point to the removed /Library/Frameworks/Python.framework directoryLuane
@mp3por - try ls -ld /usr/local/bin| grep PythonRichly
similar to #3819949Jampan
what if there is no Python.framework in /Library/Frameworks/, but there is a folder named python in /Library? Can I remove this folder?Medius
DO NOT DO THIS! This information may have been correct before, but it is dangerous to follow now. Your system needs the built-in Python to be where it expects it to be. So leave the system Python alone, and use Homebrew Python instead. See docs.brew.sh/Homebrew-and-Python.htmlHarday

© 2022 - 2024 — McMap. All rights reserved.