Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 329
Jan Deinhard Avatar asked Sep 29 '10 07:09

Jan Deinhard


People also ask

Can I uninstall Python 2.7 Mac?

It shouldn't surprise anyone that Apple is removing Python 2.7 from the upcoming macOS 12.3 release: As far back as 2019, the company said it was deprecating the scripting and programming language and that Python would not be included with future versions of the OS. Now Apple is simply making good on that promise.


2 Answers

Do not attempt to remove any Apple-supplied system Python which are in /System/Library and /usr/bin, as this may break your whole operating system.


NOTE: The steps listed below do not affect the Apple-supplied Python 2.7; they only remove a third-party Python framework, like those installed by python.org installers.


The complete list is documented here. Basically, all you need to do is the following:

  1. Remove the third-party Python 2.7 framework

     sudo rm -rf /Library/Frameworks/Python.framework/Versions/2.7 
  2. Remove the Python 2.7 applications directory

     sudo rm -rf "/Applications/Python 2.7" 
  3. Remove the symbolic links, in /usr/local/bin, that point to this Python version. See them using

     ls -l /usr/local/bin | grep '../Library/Frameworks/Python.framework/Versions/2.7'  

and then run the following command to remove all the links:

    cd /usr/local/bin/     ls -l /usr/local/bin | grep '../Library/Frameworks/Python.framework/Versions/2.7' | awk '{print $9}' | tr -d @ | xargs rm 
  1. If necessary, edit your shell profile file(s) to remove adding /Library/Frameworks/Python.framework/Versions/2.7 to your PATH environment file. Depending on which shell you use, any of the following files may have been modified: ~/.bash_login, ~/.bash_profile, ~/.cshrc, ~/.profile, ~/.tcshrc, ~/.zshrc, and/or ~/.zprofile.
like image 152
Ned Deily Avatar answered Sep 21 '22 07:09

Ned Deily


This one works:

cd /usr/local/bin/ ls -l /usr/local/bin | grep '../Library/Frameworks/Python.framework/Versions/2.7' | awk '{print $9}' | tr -d @ | xargs rm 

Description: It list all the links, removes @ character and then removes them.

like image 45
conehead Avatar answered Sep 19 '22 07:09

conehead