- List Outdated Packages
- Update All Python Packages
- Update Specific Packages On Windows Or Linux
- References
pip list --outdated
pip freeze | %{$.split('==')[0]} | %{pip install --upgrade $}
To upgrade all packages using pip with grep on Ubuntu Linux
pip3 list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip3 install -U
To upgrade all packages using pip with awk on Ubuntu Linux
pip3 list -o | cut -f1 -d' ' | tr " " "\n" | awk '{if(NR>=3)print}' | cut -d' ' -f1 | xargs -n1 pip3 install -U
-
Freeze packages
pip freeze > requirements.txt
-
Edit
requirements.txt
(set the versions you need for your project) -
Upgrade to the newer/older versions you've setted
pip install -r requirements.txt --upgrade
https://www.activestate.com/resources/quick-reads/how-to-update-all-python-packages/
Format option
freeze
is not available on Mac in Python 3.13. The follow command is more convenient by usingjq
instead of regex or other fancy string manipulation.Like @stefanos82 mentioned, it's also possible to ease the usage with the help of a
subshell
.$ pip3 install --upgrade $(pip3 list --outdated --format=json | jq -r '.[].name')
If nothing can be upgraded, the command will fail with the following