Trusted answers to developer questions

How to uninstall Python

Free System Design Interview Course

Many candidates are rejected or down-leveled due to poor performance in their System Design Interview. Stand out in System Design Interviews and get hired in 2024 with this popular free course.

Python is uninstalled differently in Windows, macOS, and Linux.

Windows

To uninstall Python from Windows, follow these steps:

  1. Navigate to the “Control Panel.”
  2. Click “Uninstall a program,” and a list of all the currently installed programs will be displayed.
  3. Select the Python version that you want to uninstall, then click the “Uninstall” button above the list. This has to be done for every Python version installed on the system.

MacOS

For Python 3 and above, first perform the following steps:

  1. Go to the “Finder.”
  2. Click “Applications” in the menu on the left.
  3. Find the Python folder with the version number you want to uninstall, right-click it, and select the “Move to Trash” option.

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.

Removing additional files from the “Terminal”

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.”

  1. Open the “Terminal” and navigate to your 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.”

Linux

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

Terminal 1
Terminal
Loading...

RELATED TAGS

python
windows
mac
Copyright ©2024 Educative, Inc. All rights reserved
Did you find this helpful?