pip Uninstall / remove a package installed with pip

We will show you how to remove the pip package that you installed with pip install. pip is a package management tool that can be used to install and manage packages of programs written in Python, which can be found in the Python Package Index (PyPI). pip is a recursive acronym that can be either “Pip Installs Packages” or “Pip Installs Python”. Alternatively, pip stands for “privileged installer program”. Let’s see how you can uninstall pip.

If you’ve followed one of our previous guides on how to install and use pip on Ubuntu 16.04, or how to install and use pip on CentOS 7 and you’ve installed some Python packages that you don’t want to use, you can easily uninstall them using pip.

First of all, connect to your Linux server using SSH. Then find out the list of currently installed packages using the following command:

pip list

The command above will give you an output similar to the one below:

# pip list
authorize (0.1.0)
backports.ssl-match-hostname (3.5.0.1)
beautifulsoup4 (4.6.0)
bs4 (0.0.1)
chardet (3.0.4)
decorator (3.4.0)
...

All of these packages are already installed via pip, and you can uninstall any package you don’t need. To remove an installed package using the command pip install, you can use pip uninstall… For example, to remove a package beautifulsoup4, you can use the following command:

pip uninstall beautifulsoup4

After executing the command, pip will ask you to confirm the action. Enter y to confirm and the package will be removed from the system.

# pip uninstall beautifulsoup4
Uninstalling beautifulsoup4-4.6.0:
...
Proceed (y/n)? y
  Successfully uninstalled beautifulsoup4-4.6.0

As you can see, removing packages with pip is as easy as installing them. Learning how you can manage packages installed on your Ubuntu VPS or CentOS VPS with pip will help you create better applications. pip is also useful for many other tasks, like updating packages that are currently installed, or installing a specific version of a package for a project. For a complete list of options that you can use with pip, you can find out via the command pip --help

[[email protected] /]# pip --help

Usage:
  pip <command></command> [options]

Commands:
  install                     Install packages.
  download                    Download packages.
  uninstall                   Uninstall packages.
  freeze                      Output installed packages in requirements format.
  list                        List installed packages.
  show                        Show information about installed packages.
  check                       Verify installed packages have compatible dependencies.
  search                      Search PyPI for packages.
  wheel                       Build wheels from your requirements.
  hash                        Compute hashes of package archives.
  completion                  A helper command used for command completion.
  help                        Show help for commands.

General Options:
  -h, --help                  Show help.
  --isolated                  Run pip in an isolated mode, ignoring environment variables and user configuration.
  -v, --verbose               Give more output. Option is additive, and can be used up to 3 times.
  -V, --version               Show version and exit.
  -q, --quiet                 Give less output. Option is additive, and can be used up to 3 times (corresponding to WARNING, ERROR, and CRITICAL logging levels).
  --log <path>                Path to a verbose appending log.
  --proxy <proxy>             Specify a proxy in the form [user:[email protected]]proxy.server:port.
  --retries <retries>         Maximum number of retries each connection should attempt (default 5 times).
  --timeout <sec>             Set the socket timeout (default 15 seconds).
  --exists-action <action>    Default action when a path already exists: (s)witch, (i)gnore, (w)ipe, (b)ackup, (a)bort.
  --trusted-host <hostname>   Mark this host as trusted, even though it does not have valid or any HTTPS.
  --cert <path>               Path to alternate CA bundle.
  --client-cert <path>        Path to SSL client certificate, a single file containing the private key and the certificate in PEM format.
  --cache-dir <dir>           Store the cache data in <dir>.
  --no-cache-dir              Disable the cache.
  --disable-pip-version-check periodically check PyPI to determine whether a new version of pip is available for download. Implied with --no-index.

For more details on how to use pip uninstall, you can refer to the pip documentation (https://pip.pypa.io/en/stable/) for pip uninstall and other usage examples.

Sidebar