thedjpetersen thedjpetersen - 2 years ago 161
Python Question

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.

rbp rbp
Answer Source

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:

  • Added a 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, though not in "requirements" format: pip list --outdated
  • Added -n1 to xargs, prevents stopping everything if updating one package fails (thanks @andsens)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download