Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable pip to upgrade all outdated packages #3819

Closed
walchko opened this issue Jun 26, 2016 · 28 comments
Closed

enable pip to upgrade all outdated packages #3819

walchko opened this issue Jun 26, 2016 · 28 comments

Comments

@walchko
Copy link

@walchko walchko commented Jun 26, 2016

  • Pip version: all
  • Python version: all
  • Operating System: all

Description:

I would like pip to upgrade all outdated packages identified by pip list --outdated in one simple command. It would also be nice to have pip outdated show the outdated package too.

What I've run:

this works for me (so far), but from a usability stand point, people shouldn't have to do this just to keep their packages up to date:

pip list --outdated | cut -d' ' -f1 | xargs pip install --upgrade
@picibucor

This comment has been minimized.

Copy link

@picibucor picibucor commented Aug 23, 2016

It does not work for Windows 7

@Kalagon

This comment has been minimized.

Copy link

@Kalagon Kalagon commented Sep 8, 2016

Well, cut and xargs are linux command line tools so it can't be expected to simply work on Windows. You would need Windows equivalents of those or maybe something like cygwin. Ignore this.

@RonnyPfannschmidt

This comment has been minimized.

Copy link
Contributor

@RonnyPfannschmidt RonnyPfannschmidt commented Sep 8, 2016

note that this is completely broken for pip style installers

unlike a linux distribution where a set of packages goes trough release and maintenance processes, with QA

pypi is a package index, not a quality assured distribution

please dont pretend it can be used like one

@Kalagon

This comment has been minimized.

Copy link

@Kalagon Kalagon commented Sep 8, 2016

Sorry, I had no idea. I've edited my original comment.

@xavfernandez

This comment has been minimized.

Copy link
Contributor

@xavfernandez xavfernandez commented Sep 28, 2016

Closing as duplicate of the requested upgrade-all command (cf #59)

@its0x08

This comment has been minimized.

Copy link

@its0x08 its0x08 commented Dec 6, 2016

pip freeze > requirements.txt && pip install --upgrade -r requirements.txt && rm requirements.txt
super easy !

@picibucor

This comment has been minimized.

Copy link

@picibucor picibucor commented Dec 6, 2016

on win:
pip freeze > requirements.txt && pip install --upgrade -r requirements.txt && del requirements.txt

@its0x08

This comment has been minimized.

Copy link

@its0x08 its0x08 commented Dec 6, 2016

@picibucor : i see -r if u dont is ur problem!

@picibucor

This comment has been minimized.

Copy link

@picibucor picibucor commented Dec 6, 2016

@its0x08 : My bad, sorry.

@gwerbin

This comment has been minimized.

Copy link

@gwerbin gwerbin commented Feb 16, 2017

@its0x08 you can do this in a Bash-flavored shell without creating a temporary file using "process substitution":

pip install --upgrade -r <( pip freeze )

Under the hood, this creates a temporary "named pipe" and then deletes it immediately after.

@pfmoore

This comment has been minimized.

Copy link
Member

@pfmoore pfmoore commented Feb 16, 2017

Two comments.

  1. pip freeze includes exact versions, so it won't upgrade as written (you'd need to add a step to strip out the version constraints).
  2. Doing this will upgrade everything to the latest versions, which won't necessarily respect dependencies. For example, bleach depends on html5lib (>=0.999,!=0.9999,!=0.99999,<0.99999999), but pip install --upgrade bleach html5lib will install html5lib-0.999999999. This is the "pip needs a dependency resolver" issue.
@nschloe

This comment has been minimized.

Copy link

@nschloe nschloe commented Mar 15, 2017

For anyone who's tired googling that command line, I've added a command line tool to pipdate. Simply

sudo -H pip install pipdate

and then

sudo -H pipdate

anytime you like.

@wblondel

This comment has been minimized.

Copy link

@wblondel wblondel commented Apr 2, 2017

Thanks a lot @nschloe !

@partounian

This comment has been minimized.

Copy link

@partounian partounian commented Apr 11, 2017

@nschloe How does that work for pip2 vs pip3? How can I run that for the nondefault pip?

EDIT: Example usage

sudo -H pipdate3

but I don't think this is necessary.

@nschloe

This comment has been minimized.

Copy link

@nschloe nschloe commented Apr 11, 2017

@partounian

How can I run that for the nondefault pip?

Not sure what you mean, but if you file an issue over at https://github.com/nschloe/pipdated I'd be happy to discuss it.

@simion

This comment has been minimized.

Copy link

@simion simion commented Apr 26, 2017

I've released a nice interactive pip requirements upgrader: https://github.com/simion/pip-upgrader

@walchko

This comment has been minimized.

Copy link
Author

@walchko walchko commented Apr 26, 2017

@simion good job! 😃

@simion

This comment has been minimized.

Copy link

@simion simion commented Apr 26, 2017

@walchko thanks! Looking forward to receive feedback and improvement ideas :)

@texadactyl

This comment has been minimized.

Copy link

@texadactyl texadactyl commented Jun 11, 2017

All of the above is exactly why pip should be modified by the maintainers to support an "upgrade-all-outdated" function that works on all platforms, similar to apt dist-upgrade on Debian-like Linux systems. The danger of work-arounds is that they tend to become obsolete and not work everywhere.

Why is this issue closed???

@goetzc

This comment has been minimized.

Copy link

@goetzc goetzc commented Jul 7, 2017

You can see above:

Closing as duplicate of the requested upgrade-all command (cf #59)

And there is also "Add an upgrade-all command" #4551

@pradyunsg

This comment has been minimized.

Copy link
Member

@pradyunsg pradyunsg commented Jul 7, 2017

@texadactyl As @goetzc said, this issue was closed as a duplicate of #59.

The discussion for adding an upgrade-all command would be done in #4551 but that is currently blocked by #988.

@Jermic

This comment has been minimized.

Copy link

@Jermic Jermic commented Jul 19, 2017

python3.6

pip list -o | cut -d " " -f 1 | tail -n +3 | xargs pip install -U
@flawiddsouza

This comment has been minimized.

Copy link

@flawiddsouza flawiddsouza commented Aug 8, 2017

In PowerShell

pip list --outdated --format=freeze | %{$_.split('==')[0]} | %{pip install --upgrade $_}
@xiaoshuai

This comment has been minimized.

Copy link

@xiaoshuai xiaoshuai commented Jan 2, 2018

i use pip list --format=legacy --outdated | cut -d' ' -f1 | xargs pip install --upgrade work fine

@ak04nv

This comment has been minimized.

Copy link

@ak04nv ak04nv commented Apr 25, 2018

pip list --format freeze | sed 's/==.*$//g' | xargs pip install -U
@paidhi

This comment has been minimized.

Copy link

@paidhi paidhi commented May 4, 2018

This should work on multiple platforms (including Windows):
pip install --upgrade $(pip list --outdated --format=json | jq '.[].name' --raw-output)

The jq executable is available for many platforms.

@xa0082249956

This comment has been minimized.

Copy link

@xa0082249956 xa0082249956 commented May 16, 2018

In PowerShell without pipelines.

pip install --upgrade ((pip freeze) -replace '==.+','')
@pradyunsg

This comment has been minimized.

Copy link
Member

@pradyunsg pradyunsg commented May 16, 2018

Hey everyone!

pip currently doesn't have a proper resolver (#988) which means that you can't be sure that installing a new package won't break a package. This means most of the commands listed here will likely break your environment in some weird way.

That said, we have a tracking issue for upgrade-all command (#4551) so I suggest you subscribe to that issue for updates on this topic.

@pypa pypa locked as resolved and limited conversation to collaborators May 16, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
You can’t perform that action at this time.