How to uninstall Python 2.7 on a Mac OS X 10.6.4?

Viewed 1065612

I want to completely remove Python 2.7 from my Mac OS X 10.6.4. I managed to remove the entry from the PATH variable by reverting my .bash_profile. But I also want to remove all directories, files, symlinks, and entries that got installed by the Python 2.7 install package. I've got the install package from http://www.python.org/. What directories/files/configuration file entries do I need to remove? Is there a list somewhere?

16 Answers

Create the symlink to latest version

 ln -s -f /usr/local/bin/python3.8 /usr/local/bin/python

Close and open a new terminal

and try

 python --version

No need to uninstall it or going crazy with symbolic links, just use an alias. I faced the same problem when upgrading to python 3.7.1.
Just install the new python version using brew install python then in your .bash_profile create an alias pointing to the new python version; like this: alias python="/usr/local/bin/python3" then save and run source ~/.bash_profile.
Done.

I faced the same problem when upgrading to python 3.9 from python 2.7.16 Just install the new python version using brew install python or download and install for your OS then

  1. sudo rm -rf /Library/Frameworks/Python.framework/Versions/2.7
    
  2. sudo rm -rf "/Applications/Python 2.7"
    
  3. ls -l /usr/local/bin | grep '../Library/Frameworks/Python.framework/Versions/2.7'
    
  4. then check -> python --version

  5. in your .bash_profile create an alias pointing to the new python version; like this:

    alias python="/usr/local/bin/python3" 
    

    then save and run source ~/.bash_profile.

  6. check -> python --version

all set now

Onur Güzel provides the solution in his blog post, "Uninstall Python Package from OS X.

You should type the following commands into the terminal:

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

  2. cd /usr/local/bin

  3. ls -l . | grep '../Library/Frameworks/Python.framework' | awk '{print $9}' | xargs sudo rm

  4. sudo rm -rf "/Applications/Python x.y"

    where command x.y is the version of Python installed. According to your question, it should be 2.7.

In Onur's words:

WARNING: This commands will remove all Python versions installed with packages. Python provided from the system will not be affected.

If you have more than 1 Python version installed from python.org, then run the fourth command again, changing "x.y" for each version of Python that is to be uninstalled.

On a MacOS where python3 was installed with brew:

sudo ln -s -f /opt/homebrew/bin/python3 /usr/local/bin/python
sudo ln -s -f /opt/homebrew/bin/pip3 /usr/local/bin/pip

Reopen terminal

python --version
pip --version

This is what worked for me on Mac OS

  1. Download the latest Python 3.x from https://www.python.org/downloads/mac-osx/

  2. Install Python 3.x by going through the Installation Steps that show up when you click on the installer

  3. ln -s -f /usr/local/bin/python3.9 /usr/local/bin/python

  4. ln -s -f /usr/local/bin/pip3 /usr/local/bin/pip

  5. Open a new terminal window and verify python --version. Should say 3.x

For step 3, confirm the path for your existing python executable by checking the output of which python

If you're thinking about manually removing Apple's default Python 2.7, I'd suggest you hang-fire and do-noting: Looks like Apple will very shortly do it for you:

Python 2.7 Deprecated in OSX 10.15 Catalina

Python 2.7- as well as Ruby & Perl- are deprecated in Catalina: (skip to section "Scripting Language Runtimes" > "Deprecations")

https://developer.apple.com/documentation/macos_release_notes/macos_catalina_10_15_release_notes

Apple To Remove Python 2.7 in OSX 10.16

Indeed, if you do nothing at all, according to The Mac Observer, by OSX version 10.16, Python 2.7 will disappear from your system:

https://www.macobserver.com/analysis/macos-catalina-deprecates-unix-scripting-languages/

Given this revelation, I'd suggest the best course of action is do nothing and wait for Apple to wipe it for you. As Apple is imminently about to remove it for you, doesn't seem worth the risk of tinkering with your Python environment.

NOTE: I see the question relates specifically to OSX v 10.6.4, but it appears this question has become a pivot-point for all OSX folks interested in removing Python 2.7 from their systems, whatever version they're running.

Caution when trying to remove certain python library, Mac OS needs python! DO NOT remove any Python versions in the following folders:

/usr/bin
system/Library

These Python 2.7 versions are installed by Apple and used by Mac OS and other software. Deleting Python from these directories can break your system.

Here you will see all the preinstalled versions of python including 2.3, 2.4 and even 2.7.

/System/Library/Frameworks/Python.framework/Versions

But, even with sudo I do not think so, you will be able to remove them. You will get an error - Operation not permitted

Related