How to Uninstall Python on macOS
- Understanding Python on macOS
- Uninstalling Python Installed with Homebrew
- Uninstalling Python Installed via pyenv
- Uninstalling the System Version of Python
- Cleaning Up Residual Files
- Conclusion
- FAQ

Uninstalling Python from your macOS can be a straightforward process, but it’s essential to follow the right steps to avoid leaving residual files behind. Whether you’re looking to free up space, switch versions, or just clean up your development environment, this tutorial will guide you through the process of uninstalling Python effectively.
In this article, we’ll explore various methods to uninstall Python and ensure that your macOS remains tidy and efficient. Let’s dive in and make sure you have a seamless experience while managing your Python installations on macOS.
Understanding Python on macOS
Before we jump into the uninstallation process, it’s crucial to understand how Python is integrated into macOS. Apple includes a version of Python with its operating system, which is used for various system tasks. Therefore, when uninstalling Python, it’s vital to identify which version you want to remove—whether it’s the system version or a version installed via Homebrew, pyenv, or another method.
Uninstalling Python Installed with Homebrew
If you’ve installed Python using Homebrew, uninstalling it is quite simple. Homebrew is a popular package manager for macOS that makes it easy to manage software installations. To uninstall Python, you’ll need to use a few commands in the terminal. Here’s how you can do it:
Open your terminal and execute the following command:
bashCopybrew uninstall python
Output:
textCopyUninstalling /usr/local/Cellar/python/3.x.x... (x,xxx files, x.xMB)
Removing: /usr/local/bin/python3
This command removes the Python version installed via Homebrew along with its associated files. If you want to remove specific versions of Python, you can specify the version number like this:
bashCopybrew uninstall python@3.x
Output:
textCopyUninstalling /usr/local/Cellar/python@3.x/3.x.x... (x,xxx files, x.xMB)
Removing: /usr/local/bin/python3.x
After executing the command, it’s a good practice to check if Python has been removed completely. You can do this by typing python3 --version
in your terminal. If Python is uninstalled successfully, you should see an error message indicating that the command was not found.
Uninstalling Python Installed via pyenv
If you’ve used pyenv to manage your Python versions, uninstalling Python is equally straightforward. Pyenv allows you to easily switch between multiple Python versions, and removing one is just as easy. Here’s how you can uninstall Python installed with pyenv:
First, check which versions of Python you have installed with:
bashCopypyenv versions
Output:
textCopy system
3.x.x
3.y.y
Next, to uninstall a specific version, use the following command:
bashCopypyenv uninstall 3.x.x
Output:
textCopyRemoving /Users/yourusername/.pyenv/versions/3.x.x
This command deletes the specified Python version and all its associated files. After uninstallation, you can verify the removal by running pyenv versions
again. The version you uninstalled should no longer appear in the list.
Uninstalling the System Version of Python
Uninstalling the system version of Python that comes pre-installed with macOS is not recommended. This version is integrated into the operating system and is used for various tasks and applications. Removing it could lead to system instability or other issues. However, if you still want to disable it, you can do so by modifying your PATH variable or using alias commands in your shell configuration file.
To disable the system version, you can add an alias to your .bash_profile
or .zshrc
file:
bashCopyecho "alias python=/usr/bin/python3" >> ~/.bash_profile
Output:
textCopyalias python=/usr/bin/python3
After adding this line, run the following command to apply the changes:
bashCopysource ~/.bash_profile
This method doesn’t uninstall the system version but redirects the command to a different Python version if you have one installed. Always be cautious when modifying system files, as this can affect the overall performance of your macOS.
Cleaning Up Residual Files
After uninstalling Python, it’s crucial to clean up any residual files that may have been left behind. These files can take up unnecessary space and clutter your system. Here’s how you can find and delete these files:
First, you can locate Python-related files by running:
bashCopyfind /usr/local -name "*python*"
Output:
textCopy/usr/local/bin/python3
/usr/local/lib/python3.x
/usr/local/etc/python3.x
Once you identify the files, you can remove them using the rm
command. For example:
bashCopyrm -rf /usr/local/bin/python3
Repeat this process for any other Python-related directories or files you find. Ensure you only delete files associated with the Python version you uninstalled. This cleanup will help maintain your macOS performance and free up valuable disk space.
Conclusion
Uninstalling Python on macOS doesn’t have to be a daunting task. Whether you used Homebrew, pyenv, or even the system installation, the methods outlined in this tutorial provide clear steps to remove Python effectively. Remember to check for any residual files after uninstallation to keep your system clean. By following these guidelines, you can manage your Python installations with ease and ensure your macOS remains efficient and organized.
FAQ
-
How do I check which version of Python is installed on macOS?
You can check the installed version by runningpython --version
orpython3 --version
in the terminal. -
Is it safe to uninstall the system version of Python?
It is not recommended to uninstall the system version as it is used for various system tasks. -
How can I reinstall Python after uninstalling it?
You can reinstall Python using Homebrew by runningbrew install python
or download it from the official Python website. -
What should I do if I encounter errors during uninstallation?
Ensure that you have the correct permissions and that you are targeting the right version of Python. Check for any running processes that may be using Python. -
Can I have multiple versions of Python installed simultaneously?
Yes, you can use tools like pyenv to manage multiple Python versions on your macOS.
Lakshay Kapoor is a final year B.Tech Computer Science student at Amity University Noida. He is familiar with programming languages and their real-world applications (Python/R/C++). Deeply interested in the area of Data Sciences and Machine Learning.
LinkedIn