Skip to content

How to upgrade all Python packages with pip

You can upgrade all installed Python packages using pip by using the pip command with the --upgrade flag. Here’s the command to do that:

Open a terminal or command prompt and enter:

pip install --upgrade pip
pip list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip install -U

Let’s break down what this command does:

  1. pip install --upgrade pip: Upgrades pip itself to the latest version.
  2. pip list --outdated --format=freeze: Lists all outdated packages in the freeze format.
  3. grep -v '^\-e': Filters out packages installed in editable mode (using -e flag).
  4. cut -d = -f 1: Cuts the output to keep only the package names without version numbers.
  5. xargs -n1 pip install -U: Iterates through each package name and upgrades it to the latest version.

This command may take some time to complete, especially if there are many packages to upgrade. After running it, all your installed Python packages should be updated to their latest versions.

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments