Is it possible to upgrade all Python packages at one time with pip
?
Note that there is a feature request for this on the official issue tracker.
Is it possible to upgrade all Python packages at one time with pip
?
Note that there is a feature request for this on the official issue tracker.
or even:
Works fast as it is not constantly launching a shell. I would love to find the time to get this actually using the list outdated to speed things up still more.
The shortest and easiest on Windows.
@Ramana's answer worked the best for me, of those here, but I had to add a few catches:
The
site-packages
check excludes my development packages, because they are not located in the system site-packages directory. The try-except simply skips packages that have been removed from PyPI.@endolith: I was hoping for an easy
pip.install(dist.key, upgrade=True)
, too, but it doesn't look like pip was meant to be used by anything but the command line (the docs don't mention the internal API, and the pip developers didn't use docstrings).This seems more concise.
Explanation:
pip list --outdated
gets lines like theseIn
cut -d ' ' -f1
,-d ' '
sets "space" as the delimiter,-f1
means to get the first column.So the above lines becomes:
then pass them to
xargs
to run the command,pip install -U
, with each line as appending arguments-n1
limits the number of arguments passed to each commandpip install -U
to be 1when using a virtualenv and if you just want to upgrade packages added to your virtualenv, you may want to do:
One-liner version of @Ramana's answer.
`