Reputation: 6477
I installed Python 3 on Mac and installed some packages as well. But then I see AWS lamda does not support Python 3 so I decided to downgrade. I removed Python3 folder in Applications and cleared the trash. But still I see a folder named 3 in /Library/Frameworks/Python.framework/Versions which is causing problems, such as this:
$ python3 -m pip install virtualenv
Requirement already satisfied: virtualenv in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (20.14.1)
Requirement already satisfied: platformdirs<3,>=2 in /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages (from virtualenv) (2.5.2)
So my question is how do I completely uninstall python 3 from my Mac?
Upvotes: 46
Views: 235897
Reputation: 1
If your version of Python was deployed, you'll also want to remove the receipt with pkgutil or else you'll run into issues trying to redeploy it in the future.
Grab the identifier from the installed package;
pkgutil --packages | grep Python
You'll be after these four. I'll be basing this on Python 3.12;
org.python.Python.PythonFramework-3.12
org.python.Python.PythonDocumentation-3.12
org.python.Python.PythonApplications-3.12
org.python.Python.PythonUnixTools-3.12
Then forget the receipts;
pkgutil --forget org.python.Python.PythonFramework-${PYTHON_VERSION_NUMBER}
pkgutil --forget org.python.Python.PythonDocumentation-${PYTHON_VERSION_NUMBER}
pkgutil --forget org.python.Python.PythonApplications-${PYTHON_VERSION_NUMBER}
pkgutil --forget org.python.Python.PythonUnixTools-${PYTHON_VERSION_NUMBER}
Upvotes: 0
Reputation: 1215
I was having problems uninstalling / removing [email protected]
Turns out I had used Homebrew to install it.
Used:
brew uninstall [email protected]
Worked like a charm.
Upvotes: 1
Reputation: 1196
Removing the app does not completely uninstall that version of Python. You will need to remove the framework directories and their symbolic links.
Deleting the frameworks
sudo rm -rf /Library/Frameworks/Python.framework/Versions/[version number]
replacing [version number] with 3.10 in your case.
Removing symbolic links
To list the broken symbolic links.
ls -l /usr/local/bin | grep '../Library/Frameworks/Python.framework/Versions/[version number]'
And to remove these links:
cd /usr/local/bin
ls -l /usr/local/bin | grep '../Library/Frameworks/Python.framework/Versions/[version number]' | awk '{print $9}' | tr -d @ | xargs rm
As always, please be wary of copying these commands. Please make sure the directories in the inputs are actual working directories before you execute anything.
The general idea in the end is to remove the folders and symlinks, and you're good to go.
Here is another response addressing this process: How to uninstall Python 2.7 on a Mac OS X 10.6.4?
Upvotes: 63
Reputation: 31860
The other answers here may become outdated if the Python installer changes what it's installed and where. However, a more general solution like this one that explains how to remove all the contents of a .pkg
file from your mac will clean up the files included with the installer, and will be resilient to most installer changes in the future.
Upvotes: 5
Reputation: 619
# 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
Upvotes: 56