How to use PIP to Uninstall a Package in Python

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

 

Windows search

 

(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 that you may come across when trying to uninstall a package.

 

Command Prompt

 

(3) In the Command Prompt, type “cd\” as this command will ensure that your starting point has only the drive name:

 

Admin command prompt

 

(4) Press Enter. Now you’ll see the drive name C:\>

 

Administrator command prompt

 

(5) Type cd followed by the path name where your Python Scripts folder is located.

In my case, I installed Python 3.6 under the Program Files (x86). And the complete path where my Scripts folder is located is: C:\Program Files (x86)\Python36-32\Scripts

 

Python - scripts

 

Once you retrieved the Python Scripts path, type it in the Command Prompt (don’t forget to type “cd” before your Python Scripts path):

 

Command prompt - Python scripts

 

(6) Press Enter, and you’ll see the following:

 

How to Install a Package in Python using PIP

 

(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:

 

Use PIP to Uninstall a Package in Python

 

To proceed with the removal of the package, type y and then press Enter:

 

Uninstall a Package using PIP

 

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.