upgrade all outdated pip packages discarding failures [duplicate]
Asked Answered
C

1

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?

Codicil answered 25/12, 2018 at 16:20 Comment(4)
stackoverflow.com/search?q=%5Bpip%5D+upgrade+%22one+by+one%22Gliwice
The key is -n1: xargs -n1 pip3 install…Gliwice
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 anywayCodicil
There's a much more elegant method involving freeze and requirements.txt, see here in github comment.Fishgig
C
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
Codicil answered 25/12, 2018 at 17:24 Comment(1)
I get an error message "--outdated" can not be used with "freeze" with pip 23.3.2 on python 3.10Maroc

© 2022 - 2024 — McMap. All rights reserved.