uninstall python on mac

How to Uninstall Python 2.7 on Mac OS

Often developers need to uninstall python 2.7 from Mac OS, especially in case they are facing any issues with it or need to upgrade it to a newer version. In this article, we will learn how to uninstall python 2.7 on Mac OS. Please note, this is not the Apple-supplied python 2.7 that is already present in your system by default. This is the python 2.7 you or third-party has installed on your system. If you delete the default python 2.7 already present on your system, it will stop functioning properly.


How to Uninstall Python 2.7 on Mac OS

As mentioned we will not be touching the default python installation files present in /System/Library and /usr/bin as it may break your system.

1. Remove Python Framework

First step is to remove python framework with the following command.

# sudo rm -rf /Library/Frameworks/Python.framework/Versions/2.7

2. Remove Python Application Directory

Next, run the following command to remove Python 2.7 application directory.

# sudo rm -rf "/Applications/Python 2.7"

3. Remove Symbolic Links

There may be a set of symbolic links in /usr/bin/local that point to your python. You can list them with the following command.

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

Remove them with the following command.

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

4. Update PATH Variable

Finally, remove path to your python installation from system’s PATH variable. Depending on your system, it may be present in any of the ~/.bash_login, ~/.bash_profile, ~/.cshrc, ~/.profile, ~/.tcshrc, ~/.zshrc, and/or ~/.zprofile files.

In this article, we have learnt how to uninstall Python 2.7 on Mac OS. Please note, this is the uninstallation of python installed by you or third-party and not the default installation already present in all Mac OS systems.

Also read:

How to Parse URL Into Hostname and Pathname
How to Remove Element by ID in JS
How to Write to File in NodeJS
How to Export JS Array to CSV File
How to Convert Unix Timestamp to Datetime in Python

Leave a Reply

Your email address will not be published. Required fields are marked *