How to upgrade all Python packages with pip?

Better Stack Team
Updated on January 26, 2023

You can use the pip install command with the --upgrade option to upgrade all packages in your Python environment.

Here's the basic syntax:

pip install --upgrade [package1] [package2] ...

To upgrade all packages, you can use the * wildcard:

pip install --upgrade *

This will upgrade all packages in your environment to the latest version that is compatible with the other packages in your environment.

Alternatively, you can use the pip freeze command to generate a requirements file that lists all the packages in your environment, and then use the pip install -r command to upgrade all the packages at once:

pip freeze > requirements.txt
pip install --upgrade -r requirements.txt

This can be especially useful if you have a lot of packages installed, as it allows you to version control your package dependencies and easily replicate your environment on another machine.

Got an article suggestion? Let us know
Explore more
Licensed under CC-BY-NC-SA

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

We are hiring.

Software is our way of making the world a tiny bit better. We build tools for the makers of tomorrow.

Explore all positions →