14

I have a bash command to upgrade all pip packages that I installed.

The command is:

pip3 list --outdated | cut -d' ' -f1 | tail -n +3 | xargs pip3 install --upgrade

The problem is that if one of the packages fails to upgrade, it rolls back deleting the upgrades of the ones that were successful upgraded.

Is there a way to upgrade all outdated packages with a single command discarding the failures of some packages?

roschach
  • 8,390
  • 14
  • 74
  • 124
  • https://stackoverflow.com/search?q=%5Bpip%5D+upgrade+%22one+by+one%22 – phd Dec 25 '18 at 17:15
  • The key is `-n1`: `xargs -n1 pip3 install…` – phd Dec 25 '18 at 17:16
  • which key? By the way the solution in the link you posted worked adding `--user` at the end. Complete command: `pip3 list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip3 install -U --user`. Thank you anyway – roschach Dec 25 '18 at 17:23
  • There's a much more elegant method involving `freeze` and `requirements.txt`, [see here in github comment](https://github.com/pypa/pip/issues/3819#issuecomment-265135462). – xdavidliu Aug 28 '22 at 00:53

1 Answers1

13

I slightly modified the command posted in the duplicate of link.

pip3 list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1  | xargs -n1 pip3 install -U --user
roschach
  • 8,390
  • 14
  • 74
  • 124