Last Updated: December 01, 2017
· lotia

update all installed python packages with pip

Edit: Don't use this tip, see comment below by @areski for a much better and safer way to do it. Not as fire and forget as my tip below, but significantly more robust practice.

pip install -U $(pip freeze | awk '{split($0, a, "=="); print a[1]}')

The -U option (or --upgrade) for pip install can take multiple arguments. The subshell finds all installed python packages using pip freeze and pipes the results to awk which populates an array a with each package name split on the == string.

Element [1] in a is the name of each package.

I find this quite handy to upgrade all the packages in various python virtualenvs.

Say Thanks

3 Responses
Add your response


That sounds quite a bad idea to upgrade without control. You might want to check pip-tools : https://github.com/nvie/pip-tools
It s a great tool to achieve an update of your pip dependencies.

over 1 year ago ·

Excellent point. I would only use the above in a development virtualenv but @areski has pointed me to a much better way of doing things.

over 1 year ago ·

You can also use this awesome interactive package upgrader: https://github.com/simion/pip-upgrader

7 months ago ·