Python is uninstalled differently in Windows, macOS, and Linux.
To uninstall Python from Windows, follow these steps:
For Python 3 and above, first perform the following steps:
Depending on the process of installation, Python might or might not be present in the “Applications” folder. If it’s not, perform the steps in the next section.
Moving the Python application to trash will not remove Python entirely. Furthermore, a built-in Python distribution might not appear in the “Applications” folder. So we’ll have to use the “Terminal” to uninstall it manually.
First, open the “Activity Monitor” and close all processes related to Python in the “Memory” tab. One such process is the “Python Launcher.” Now we can proceed to the “Terminal.”
Library
folder from your root directory:$ (base) Username:~ cd Library
Here, we can list the current folders in our Library
using the ls
command. Look for a folder named Python
. Remove this folder with super-user privileges:
sudo rm -rf Python
Note: The operation requires your password in order to be completed.
Additionally, three more main directories have to be handled in order to remove Python. Move back to your root user directory and perform the following commands:
sudo rm -rf “/Applications/Python”
sudo rm -rf /Library/Frameworks/Python.framework
sudo rm -rf /usr/local/bin/python
Note: We don’t recommend this step for novice macOS users. The way Python files are distributed in your Library and cache can differ based on your use, and so, extra files might have to be deleted, which you can search for in the “Finder” or manually in the “Terminal.”
To remove Python and its associated dependencies, you can use the following command:
apt-get -y remove --auto-remove python3.11
This command removes the Python 3.11 package and any other packages that were installed as dependencies but are no longer needed. You can replace python3.11
with any desired version that you wish to uninstall.
Let's test the above command and verify whether it can uninstall Python or not. After running the command, please execute the python --version
command to confirm the uninstallation of Python