In this short tutorial, I’ll show you how to use PIP to uninstall a package in Python. I’ll use a simple example to uninstall the pandas package.
But before we begin, here is the generic form that you can use to uninstall a package in Python:
pip uninstall package name
Now, let’s suppose that you already installed the pandas package using the PIP install method, but now you decided that you no longer need that package.
So how would you remove the package?
In the next section, I’ll show you the steps in Windows to remove a package from Python.
Steps to use PIP to Uninstall a Package in Python
(1) First, type Command Prompt in the Windows Search Box:
(2) Right click on the Command Prompt, and then select Run as administrator (by running the Command Prompt as an administrator, you’ll avoid any permission issues):
(3) In the Command Prompt, type “cd\” as this command will ensure that your starting point has only the drive name:
(4) Press Enter. Now you’ll see the drive name C:\>
(5) Locate your Python Scripts path. The Scripts folder can be found within the Python application folder, where you originally installed Python.
In my case, the Python Scripts path is:
C:\Users\doron\AppData\Local\Programs\Python\Python37\Scripts
In the Command Prompt, type cd followed by your Python Scripts path:
(6) Press Enter, and you’ll see the following:
(7) Finally, to uninstall the package in Python, use the command structure that we saw before:
pip uninstall package name
And for our example, type: pip uninstall pandas and then press Enter:
To proceed with the removal of the package, type y and then press Enter:
Your Python package will now be removed from Python.
What if you changed your mind, and decided to install that package again?
If that’s the case, you may use the PIP install method to add the package into Python.