How To Uninstall A Package with Pip? – POFTUT

How To Uninstall A Package with Pip?


Python Pip command provides search, install, update, uninstall packages. We can use pip command to uninstall packages easily even there are some alternatives like easy_install.

List Already Installed Python Packages with Pip

Before uninstalling or removing Python packages with pip we will list already installed Python packages. We will use list command for pip like below.

$ pip list
List Already Installed Python Packages with Pip
List Already Installed Python Packages with Pip

We can see that the following information is provided by listing installed packages.

  • `Package` column shows the package complete name
  • `Version` column shows the most recent version of the given package

List/Display Python Packages Information, Version

We can also show a given package complete information with the show command which can be useful before uninstalling it. In this example, we will show information about the Python package named Django.

$ pip show django
List/Display Python Packages Information, Version
List/Display Python Packages Information, Version

Uninstall/Remove Python Package with Pip, Pip2, Pip3

We can uninstall the package with the uninstall pip command. We will also provide the package name. In this example, we will uninstall the package named django.

$ pip uninstall django
Uninstall/Remove Python Package with Pip
Uninstall/Remove Python Package with Pip

We can see that the directories and files removed are listed and a confirmation is shown where we will input y in order to accept the removal. After the remove/uninstall completed we will be shown Successfully uninstalled Django-2.2.5

If we want to remove packages related to the Python2 we can use the same command for the pip2command like below.

$ pip2 uninstall django

If we want to remove packages related to the Python3 we can use the same command for the pip3command like below.

$ pip3 uninstall django

Uninstall/Remove Python Package with Requirements with Pip

Modern Python applications and projects provide the required files in order to list the package list which should be installed. We can use this requirement file in order to specify the packages we have to remove the requirement file. In this example, the requirement file contains the following content with the name of requirements.txt.

django
pycups
PyGObject
PyJWT
pymacaroons
PyNaCl
pyRFC3339

AND we will remove this requirements.txt file content like below.

$ pip uninstall requirements.txt

Uninstall/Remove Python Package Without Asking Confirmation with Pip

By default the package uninstallation or removal requires a confirmation from the user. This is generally providing the y which is a short form of Yes to accept package uninstall. We can automatically accept the confirmation and skip it with the -y or --yes option like below.

$ pip uninstall -y django

$ pip2 uninstall -y django

$ pip3 uninstall -y django

Uninstall/Remove Python Package For Specific User with Pip

pip Python packages may be installed for a specific user into the users home directory. So we can uninstall given python package for a specific user with the --user option by providing the user name. In this example, we will remove packages for the current user.

$ pip uninstall --user django

$ pip2 uninstall --user django

$ pip3 uninstall --user django

Uninstall/Remove Python Package with easy_install

We can also use the easy_install command in order to remove installed python packages. We will use -m option and provide the package name. In this example, we will remove the package named django with the easy_install command.

$ easy_install -m django

LEARN MORE  How To Install and Use OpenSSL Library In Python Applications?

1 thought on “How To Uninstall A Package with Pip?”

Leave a Comment