pip is the package manager for Python. We can use pip to install new Python packages, and keep all of our existing packages up to date. In this tutorial, we will see how to update a package via pip on Linux.
Use pip to Update Packages
Example 1. To update the pip package manager itself:
$ pip install --upgrade pip
Example 2. To check what packages need to be updated:
$ pip list --outdated
Example 3. To update a python package with pip, use the --upgrade
or -U
options:
$ pip install --upgrade package_name $ pip install -U package_name
Example 4. To upgrade all outdated pip packages at once, we can use this command:
$ pip freeze | awk -F"==" '{print $1}' | xargs -i pip install -U {}
How it works: pip freeze
will output all installed packages, awk
will isolate the package names, and xargs
will hand off each package name to the pip install -U
command, which upgrades each package.