Upgrading all packages with pip
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.
There isn't a built-in flag yet, but you can use
pip freeze --local | grep -v '^-e' | cut -d = -f 1 | xargs -n1 pip install -U
Note: there are infinite potential variations for this. I'm trying to keep this answer short and simple, but please do suggest variations in the comments!
Relevant edits:
grep
to skip "-e" package definitions, as suggested by @jawache (Yes, you could replace grep
+ cut
with sed
or awk
or perl
or...). Newer versions of pip
allow you to list outdated packages:
pip list --outdated --format=freeze
Added -n1
to xargs
, prevents stopping everything if updating one package fails (thanks @andsens)
You can use the following Python code. Unlike pip freeze
, this will not print warnings and FIXME errors.
import pip
from subprocess import call
packages = [dist.project_name for dist in pip.get_installed_distributions()]
call("pip install --upgrade " + ' '.join(packages), shell=True)
To upgrade all local packages; you could use pip-review
:
$ pip install pip-review
$ pip-review --local --interactive
pip-review
is a fork of pip-tools
. See pip-tools
issue mentioned by @knedlsepp. pip-review
package works but pip-tools
package no longer works.
pip-review
works on Windows since version 0.5.
上一篇: 用pip安装特定的软件包版本
下一篇: 用pip升级所有软件包