quwaxa
Last Updated: December 01, 2017
·
19.32K
· lotia
B9d7297223985ffafd0b1981b6cdcb28

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
Respond

3 Responses
Add your response

5374
2319bfc31c8757d206a3df6b34d9a852

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 ·
5376
B9d7297223985ffafd0b1981b6cdcb28

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 ·
28866

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

7 months ago ·