- 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/
The
jq
is an added dependency on user's side; logically and probably AWK is installed on any UNIX and UNIX-like environments - one of them is Mac and I hope I'm not wrong - as there are many scripts that are being used by the system in various areas behind the scenes.The alternative to
jq
command is the following (I will be usingpip
for both Python2 and Python3):pip install --upgrade $(pip list --outdated | awk 'NR>2 {print $1}')