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
Answer from zipzit on Stack ExchangeYes, you can trust the old references, as written! That guidance is still valid.
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.
Catalina comes with python3 installed by default**. You can't delete it, because /usr/bin is on the System's read-only volume.
If you install your new python to a bin folder that comes before /usr/bin in your $PATH, then it should take precedence.
** (Well OK, the first time you run it, you have to install Xcode command line tools to make it work. But that file itself is a system install.)
You simply specify the version like this:
brew uninstall [email protected]
How to completely uninstall Python 3 on macOS? - Stack Overflow
How to fully uninstall Python 3 on macOS Catalina? - Ask a Question - TestMu AI Community
macbook pro - Cannot uninstall Python from homebrew - Ask Different
Uninstall Python-3.10 clearly on Mac
Is Python installed on Mac by default?
Where is Python on macOS?
How to check if Python is installed on Mac?
Videos
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
Since you have used brew, you may have several Python versions, since some other bottles may need different versions. Check your installation with brew list and you may find out the [email protected] or [email protected], and decide what to uninstall, but using the real name as is in list. You may check dependencies with brew deps --tree --installed.
As the package is called python3, try:
brew uninstall python3
As a student, I had to install python and work with it. At some point my TA "fixed" an issue where now when I attempt to use PIP installations, I'm getting errors. I'm getting:
bash: pip: command not found
and
/opt/homebrew/opt/python@3.11/bin/python3.11: bad interpreter: No such file or directory
When attempting to google up advice, I'm seeing a reinstall is needed. So how do I uninstall everything completely so I can do a good reinstall?
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.