How to Uninstall Python3 on MacOS?

Uninstall Python3 X On MacOS

Python is one of the most popular programming languages used today for everything from web development and scientific computing to machine learning and data analysis. While Python comes pre-installed on MacOS, you may eventually want to uninstall Python, whether to upgrade to a newer version or remove it completely from your system.

The easiest way to fully uninstall Python 3 from MacOS is to delete the Python application, remove any related symlinks in /usr/local/bin, get rid of pip/virtualenvs/cached files using sudo rm, and delete remaining Python directories with find / -name “Python” -exec rm -rf {} \;. Checking which python should then return an error, indicating Python is removed. Be sure to back up any files first!

This step-by-step guide will walk you through the process of fully removing Python 3 and its related components from your MacOS machine.

Also read: [Fix] Bash: Python3: command not found When Installing discord.py on Windows

Reasons to Uninstall the Default Python

There are a few common reasons you may want to uninstall Python from your Mac:

  • Upgrade to a Newer Python Version – If you want to upgrade to a newer version of Python (e.g. from Python 3.7 to 3.8), completely uninstalling the previous Python version clears away any potential conflicts.
  • Remove No Longer Needed Packages – If you installed Python for a short-term project or no longer need it on your system, you can optimize storage space by deleting it.
  • Eliminate Issues/Bugs – If you are experiencing crashes, import errors, or other bugs with your Python installation, fully removing and reinstalling Python can help resolve underlying issues.
  • Change Installation Method – Transitioning to a version manager like pyenv or Anaconda may require removing any existing Python installations.

Before uninstalling, ensure you have copies of any important Python programs or packages you want to save. The uninstall process will delete everything Python-related on your system.

Step-by-Step Guide to Uninstall Python on MacOS

Uninstalling Python on Mac requires removing the Python application itself plus any related packages, cached files, and symlinks. Here is the full process:

Step 1: Remove the Python Framework

The first step is to remove the actual Python framework.

  1. Open Finder and go to your Applications folder
  2. Drag the Python 3 app to the Trash (may be called Python 3.7, Python 3.8 etc depending on your version)

Deleting this application will remove the central Python executable file.

However, we need to delete many hidden folders and symlinks related to Python.

Even after removing the Python application, symlinks to Python still exist on your system that can cause conflicts.

To list all symlinks, open Terminal and type:

ls -la /usr/local/bin | grep "../Frameworks/Python.framework/Versions"

This will print any Python symlinks in /usr/local/bin.

Next, delete the symlinks by running:

sudo rm /usr/local/bin/the_symlink_name

For example, if you see a symlink called /usr/local/bin/python3, run:

sudo rm /usr/local/bin/python3

Repeat this for EVERY symlink returned from the initial list command. This cleans up leftover Python references.

Step 3: Remove pip and virtual environments

Next, we need to remove any Python package manager files. Even if Python itself is gone, these can still take up disk space and cause conflicts.

To remove pip, run:

sudo rm -rf /Library/Frameworks/Python.framework/Versions/3.8/bin/pip3*  

Make sure to use your specific Python version if different from 3.8.

Next, remove any virtual environments:

sudo rm -rf ~/Library/Python/3.8/lib/python/site-packages/

And remove cached Python files:

sudo rm -rf ~/Library/Caches/pip

Step 4: Delete remaining Python directories

At this point, Python should be mostly removed from your Mac. However, some empty Python directories may still be present.

To delete these, run the following clean up script:

find / -name "*Python*" -exec rm -rf {} \;
find / -name "*python*" -exec rm -rf {} \; 

This will search your entire system and delete any leftover folders with “python” or “Python” in the name.

Run this several times to ensure you catch everything.

Once finished, Python should be completely wiped from your system!

Step 5: Validate the Uninstallation

As one final check, run the following command:

which python3

If Python was successfully uninstalled, you should see an error like:

python not found

Rather than pointing you to an executable Python file.

If Python still seems to be lurking, repeat the symlink removal and folder deletion steps above.

Step 6: Reinstall a New Python Version (Optional)

If you only uninstalled Python in order to upgrade versions or switch installation methods, you can reinstall Python:

  • To install the latest Python 3 release, run: brew install python
  • For a specific minor version, use: brew install [email protected]
  • You can also install Python via pyenv

Read: Step-by-Step Guide to Installing Python Using Conda

Key Benefits of Removing Python from MacOS

Fully uninstalling Python offers the following advantages:

  • Frees up disk space by removing unneeded files
  • Eliminates version conflicts if upgrading Python versions
  • Gets rid of bugs or issues with a botched installation
  • Allows a clean install of Python via symlink managers like pyenv
  • Avoids package conflicts between Python environments

So while removing Python may seem like an advanced maneuver, there are many benefits for developers and Pythonistas. Follow the steps in this guide to smoothly delete Python and reclaim disk space on your Mac. Did you find this guide helpful for uninstalling Python on your Mac? Let us know if you have any other useful tips!