Last Updated: January 28, 2019
· 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.

6 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

over 1 year ago ·

another way (assuming a standard linux/bsd environment):

sudo pip install -U $(pip freeze | cut -d '=' -f 1)

where pip should be replaced with pip2 or pip3 depending on what it's called in your distro.

9 months ago ·

You can learn from these gguys www.monkfox.com

4 months ago ·