Do not attempt to remove any Apple-supplied system Python which are in /System/Library and /usr/bin, as this may break your whole operating system.
NOTE: The steps listed below do not affect the Apple-supplied Python 2.7; they only remove a third-party Python framework, like those installed by python.org installers.
The complete list is documented here. Basically, all you need to do is the following:
Remove the third-party Python 2.7 framework
sudo rm -rf /Library/Frameworks/Python.framework/Versions/2.7Remove the Python 2.7 applications directory
sudo rm -rf "/Applications/Python 2.7"Remove the symbolic links, in
/usr/local/bin, that point to this Python version. See them usingls -l /usr/local/bin | grep '../Library/Frameworks/Python.framework/Versions/2.7'
and then run the following command to remove all the links:
cd /usr/local/bin/
ls -l /usr/local/bin | grep '../Library/Frameworks/Python.framework/Versions/2.7' | awk '{print $9}' | tr -d @ | xargs rm
- If necessary, edit your shell profile file(s) to remove adding
/Library/Frameworks/Python.framework/Versions/2.7to yourPATHenvironment file. Depending on which shell you use, any of the following files may have been modified:~/.bash_login,~/.bash_profile,~/.cshrc,~/.profile,~/.tcshrc,~/.zshrc, and/or~/.zprofile.
I currently have 3.10x and 3.11.x and I want to know how can I uninstall the older version of python I have ?
also for future how do I upgrade from 3.11.2 to say 3.11.4 or 3.12.x
install - Remove and Reinstall Python on Mac -- Can I trust these old references? - Ask Different
How to remove all old installs of Python on iMac M1
How to completely uninstall Python 3 on macOS? - Stack Overflow
terminal - My Mac has Python3 and 2.7 installed. How do I uninstall Python3 but keep 2.7? - Ask Different
Do I need to uninstall the version of Python that came with my Mac?
Is Python installed on Mac by default?
How do I uninstall Python from Terminal?
Videos
Do not attempt to remove any Apple-supplied system Python which are in /System/Library and /usr/bin, as this may break your whole operating system.
NOTE: The steps listed below do not affect the Apple-supplied Python 2.7; they only remove a third-party Python framework, like those installed by python.org installers.
The complete list is documented here. Basically, all you need to do is the following:
Remove the third-party Python 2.7 framework
sudo rm -rf /Library/Frameworks/Python.framework/Versions/2.7Remove the Python 2.7 applications directory
sudo rm -rf "/Applications/Python 2.7"Remove the symbolic links, in
/usr/local/bin, that point to this Python version. See them usingls -l /usr/local/bin | grep '../Library/Frameworks/Python.framework/Versions/2.7'
and then run the following command to remove all the links:
cd /usr/local/bin/
ls -l /usr/local/bin | grep '../Library/Frameworks/Python.framework/Versions/2.7' | awk '{print $9}' | tr -d @ | xargs rm
- If necessary, edit your shell profile file(s) to remove adding
/Library/Frameworks/Python.framework/Versions/2.7to yourPATHenvironment file. Depending on which shell you use, any of the following files may have been modified:~/.bash_login,~/.bash_profile,~/.cshrc,~/.profile,~/.tcshrc,~/.zshrc, and/or~/.zprofile.
This one works:
cd /usr/local/bin/
ls -l /usr/local/bin | \
grep '../Library/Frameworks/Python.framework/Versions/2.7' | \
awk '{print $9}' | \
tr -d @ | \
xargs rm
Description:
It list all the links, removes @ character and then removes them.
So, I ended up removing all python installations, and reinstalling things via Homebrew.
which python--->/Library/Frameworks/Python.framework/Versions/2.7/bin/pythonDelete the entire Python.framework directory from/Library/Frameworks.which python3--->/usr/local/bin/python3Delete the entire python3 directory.I was a bit nervous about the symlinks. I initially renamed the ones that were obviously going to cause me trouble. It turns out that was unnecessary. Instead, just use:
$ brew doctor Warning: Broken symlinks were found. Remove them with 'brew prune': /usr/local/bin/python-32 /usr/local/bin/python2-32 /usr/local/bin/python2.7-32 /usr/local/bin/python2_DNU /usr/local/bin/python_DNU /usr/local/bin/pythonw-32 /usr/local/bin/pythonw2-32 /usr/local/bin/pythonw2.7-32So,
brew prune(orbrew cleanup --prunein newer versions of Homebrew) worked perfectly. It removed all of the above symlinks.Reinstall python and python3 via homebrew. All done.
At no time did I touch the python installation located within the /System folder.
Oh, and to be clear. The answer to the original question is
Yes, you can trust the old references, as written! That guidance is still valid.
My Python version was 3.6, I wanted to upgrade to 3.7 (In case you have similar requirements). I am using macOS version 10.12.6 and simply uninstalling and re-installing worked for me:
brew uninstall --ignore-dependencies python3
Then:
brew install python3
and done:
python3
Python 3.7.2 (default, Jan 13 2019, 12:51:54)
[Clang 9.0.0 (clang-900.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
WARNING: macOS comes with a system Python installation in /usr/bin/python3 that should NOT be removed as it's required for system functionality. Only remove Python versions you've manually installed.
Please read the end of 5.1.1 for official insight: https://docs.python.org/3/using/mac.html#installation-steps
Legacy Python
The previous edit for this question suggested removing /Library/Frameworks/Python.framework/Versions/2.x/bin/python as a way of completely removing Python. This flexibility has since changed with newer macOS updates.
Identify Your Python Installations
Before removing anything, determine which Python installations exist and where they're located:
# List all Python installations
which -a python python3
# Check Python versions
python3 --version
# Find installation locations
ls -l /opt/homebrew/bin/python*
ls -l /usr/local/bin/python*
ls -l /usr/bin/python*
For Homebrew Python
# Uninstall Python
brew uninstall [email protected]
# Remove orphaned files
brew cleanup
# List any broken symlinks, etc.
brew doctor
For Python.org installer
# Remove the application
sudo rm -rf /Applications/Python\ 3.x
# Check for framework files
ls -la /Library/Frameworks/Python.framework/Versions/
# If found, remove the specific version
sudo rm -rf /Library/Frameworks/Python.framework/Versions/3.x
# Check for and remove symbolic links
# For Intel Macs:
cd /usr/local/bin
ls -l | grep '../Library/Frameworks/Python.framework/Versions/3.x' | awk '{print $9}' | xargs rm -f
# For Apple Silicon:
cd /usr/local/bin
ls -l | grep '../Library/Frameworks/Python.framework/Versions/3.x' | awk '{print $9}' | xargs rm -f
# Check for user-specific packages
ls -l ~/Library/Python/
# Remove if needed
rm -rf ~/Library/Python/3.x/
For pyenv-managed Python
# List all installed Python versions
pyenv versions
# Show the current active version
pyenv version
# Uninstall a specific version
pyenv uninstall 3.x.y
# Check pyenv installation location
ls -la ~/.pyenv/versions/
# Remove pyenv shims and rehash
pyenv rehash
# If you want to completely remove pyenv itself
# For Homebrew installation:
brew uninstall pyenv
# For manual installation:
rm -rf ~/.pyenv
# Don't forget to remove pyenv initialization from your shell profile
# (.bash_profile, .zshrc, etc.)
Clean Up Remaining Files
# Remove Python cache files
find ~/ -name "__pycache__" -type d -exec rm -rf {} +
find ~/ -name "*.pyc" -delete
# Check for any remaining Python-related directories
ls -la ~/Library/Application\ Support/ | grep -i python
ls -la ~/Library/Caches/ | grep -i python
# The version of Python that you want to delete
python_version_number=3.10
sudo rm -rf /Library/Frameworks/Python.framework/Versions/${python_version_number}/
sudo rm -rf "/Applications/Python ${python_version_number}/"
cd /usr/local/bin && ls -l | grep "/Library/Frameworks/Python.framework/Versions/${python_version_number}" | awk '{print $9}' | sudo xargs rm
Python.org has added uninstall directions to the documentation:
http://docs.python.org/3/using/mac.html
Reading this and then inspecting my install, my list of things to uninstall is:
- MacPython 3.3 folder in your Applications folder.
- /Library/Frameworks/Python.framework
- about 20 symlinks in /usr/local/bin.
- reference in shell path (if exists)
Using Text Wranger, which can show invisible files, I browsed my home folder and I didn't see a .bash_profile, just .bash_history. So the installer only adds the reference if the Bash profile exists. (echo $path) didn't show either. (see also: https://stackoverflow.com/questions/7501678/set-environment-variables-on-mac-os-x-lion)
The installer package really should include an uninstall script.
As of April 2013 most tutorials and courses still require Python 2, so many people will need to uninstall Python 3.
How did you install it? If you used an installer, then follow yoda's wise advice. Open a terminal and remove the directory /System/Library/Frameworks/Python.framework/Versions/3.0 if it exists. You should also make sure that the symlink /System/Library/Frameworks/Python.version/Versions/Current does not point to 3.0. If it does, then reset it to point to 2.6 or something appropriate.
There’s no need to uninstall python3 if you remove the executable from your path. Just keep calling the older version or use a tool like pyenv to juggle which is preferred if you don’t like or care to control your path.
You may have multiple versions of Python 3.x installed on your Mac. To uninstall all of them, first check which are installed:
brew list | grep python
Let's say you have 3.9 and 3.7 installed. To remove 3.9, run this command:
brew uninstall [email protected]
To remove 3.7, just replace 3.9 with 3.7 above.
rmtree verb is not available in the default install of Homebrew.
MacBook-Pro:~ admin$ brew rmtree python3
Error: Unknown command: rmtree
You can use uninstall verb as:
MacBook-Pro:~ admin$ brew uninstall python3
Uninstalling /usr/local/Cellar/python/3.6.5... (5,102 files, 102.9MB)
MacBook-Pro:~ admin$ python3
-bash: python3: command not found
MacBook-Pro:~ admin$ python
Python 2.7.10 (default, Oct 6 2017, 22:29:07)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
However, rmtree can be installed by executing the following:
$ brew tap beeftornado/rmtree
$ brew rmtree <package>
Using rmtree, one can cleanly and completely remove a package installed from Homebrew, along with all of its dependencies.
Yes, it's safe.
The Mac's system python's are in /System/Library/....
.dmg's downloaded and installed from python.org are placed in /Library/....
Don't delete the /System ones, but the /Library ones are user installed, so they should be safe to delete.
No, it's not safe. Generally, don't mess with the Python that comes with your OS, many system tools depends on having a specific version of Python.