Skip to main content

How to Safely Uninstall Python from Mac OS X


Mac Laptops comes with Python pre-installed, but if you install another version of Python probably from www.python.org it might interfere with the default Python installation. Thus it is recommended to install other Python versions through Homebrew or mac ports.


But If you happen to install another version of Python in your mac it is bit tricky to uninstall as it is not straightforward. Don't worry in this post I have listed the steps to uninstall. I have tried this in OS X Version 10.9.3.

Step 1: Check Python installations

Run the following commands to identify the active Python version and the mac system Python versions respectively.

python -V
/usr/bin/python -V

If you have installed Python then these two will show two different version numbers.

Step 2: Edit path

In the home directory you will find a file called .bash_profile and if you open it, it will contain the following following (you can open it by typing following command in terminal “vi .bash_profile”).

# Setting PATH for Python 2.7
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/2.7/local/bin:${PATH}"
export PATH

If your mac had the .bash_profile created before you installed the Python, it might have been backed up into the file .bash_profile.pysave, otherwise you won’t find any. If you have the backed up file then restore it, else create a new file with the .bash_profile file name and include the following in it.

PATH="/usr/local/bin:$PATH"
export PATH

Step 3: Remove the Python 2.7 framework and Python 2.7 applications directory

Step 2 removed the path to the installed Python, but all the installation files will remain in your mac. You can remove those files by running the following command in the terminal.

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

sudo rm -rf "/Applications/Python 2.7"

Step 4: Remove the symbolic links 

Remove the symbolic links in /usr/local/bin that point to this Python version. If you run the following command it will display those links.

ls -l /usr/local/bin

If you have already installed Homebrew just run the following command to remove those symbolic links.

brew prune

p.s. If you want to edit paths file use the following command

sudo open -t /etc/paths


You may also interested in reading:

Comments