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.
Related protips:
Written by Ali Asad Lotia
Related protips
6 Responses
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.
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.
You can also use this awesome interactive package upgrader: https://github.com/simion/pip-upgrader
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.
Excellent point. I would only use the above in a development virtualenv
Thanks, I found a few options for myself that I will try