Uninstalling User-Installed Python from macOS Sierra

macOS Sierra comes with a built-in default Python installation. On macOS Sierra 10.12.6, this default installation is on the /System/Library/Frameworks folder (which, by the way, is a critical system folder and should not be touched). macOS Sierra 10.12.6 comes with Python 2.7, which is getting outdated very fast, and also Apple itself recommends officially that to run a coding project, users should install their own updated version of Python with their own dependencies setup.

I had installed Python 2.7 myself last year when I was in a mood to start working on Python, and at that time I didn’t know that Python comes installed in macOS by default. Now I have to start working with Python in earnest for a project, and wanted to uninstall the custom Python 2.7 installation, so that I can start from scratch on a new installation of Python 3. This required some web-surfing, and some hours to figure out how to do it properly. After reading and deciphering some posts by others, I can now give an updated clean solution.

This assumes you have a good knowledge of shell / bash usage. This works for Python 2.7 installed by the user, but I am sure it works the same if you want to uninstall Python 3 from macOS Sierra too.

  • Step 1: Manually remove Python 2.7 folder from Applications (drag to Trash).
  • Step 2: Remove the Python 2.7 framework from /Library through the terminal:   sudo rm -rf /Library/Frameworks/Python.framework
  • Step 3: Clear python files from /usr/local/bin:      sudo rm -rf /usr/local/bin/python*
  • Step 4: Clear symbolic links to deleted Python files. If you have Homebrew installed already (highly recommended), then simply run brew doctor first, which will show you the broken symbolic links. Then just run brew prune to fix them (you can check it by running brew doctor again). If you don’t have Homebrew installed, then follow Step 3 here.

For more discussions, see this, this, and this.

Now we are ready for a fresh Python install from scratch!

NOTE: After uninstallation, I do need to fix the system to call the default python version installed in macOS Sierra. Probably need to revise some path specifications. But I am more concerned with the new Python3 installation at this point :). See here for more on this.

CAUTION: Under no circumstances should you try to delete or touch anything in the /System or /usr/bin/python folders. This can cause your macOS to malfunction, your Macbook could self-destruct, and there is a possibility of an alien invasion as well. If you don’t believe me, just do a web search on why not to touch anything in the macOS /System folder.

Advertisements
This entry was posted in Uncategorized on by .

About WQ

I received my PhD (2013) in Remote Sensing, Earth and Space Science at the Dept. of Aerospace Engineering Sciences, University of Colorado, Boulder, USA, under a Fulbright fellowship. Currently, I'm an Assistant Professor in the Dept. of Space Science at Institute of Space Technology (IST), Islamabad, Pakistan, where I have been a founding member of the Geospatial Research & Education Lab (GREL). My general expertise is in Remote Sensing where I have worked with various remote sensing datasets through my career, while for my PhD thesis I specifically worked on Remote Sensing using SAR (Synthetic Aperture Radar) and Oceanography, working extensively on development of techniques to measure ocean surface currents from space-borne SAR intensity images and interferometric data. My research interests are: Remote sensing, Synthetic Aperture Radar (SAR) imagery and interferometric data processing & analysis, Visible/Infrared/High-resolution satellite image processing & analysis, Oceanography, Earth system study and modelling, LIDAR data processing and analysis, Scientific programming. I am a reviewer for IEEE Transactions on Geoscience & Remote Sensing, Forest Ecosystems, GIScience & Remote Sensing, Journal of African Earth Sciences, and Italian Journal of Agronomy. I am an alumnus of Pakistan National Physics Talent Contest (NPTC), an alumnus of the Lindau Nobel Laureate Meetings, a Fulbright alumnus, and the Pakistan National Point of Contact for Space Generation Advisory Council (SGAC). I was an invited speaker at the TEDxIslamabad event held in Nov., 2014. I've served as mentor in the NASA International Space App Challenge Islamabad events in April 2015 and April 2016.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s