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.
Join Stack Overflow to learn, share knowledge, and build your career.
|
Is it possible to upgrade all Python packages at one time with 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
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:
|
|||||||||||||||||||||
|
|
You can use the following Python code. Unlike
|
|||||||||||||||||||||
|
|
To upgrade all local packages; you could use
|
|||||||||||||||||||||
|
|
Works on Windows. Should be good for others too. ($ is whatever directory you're in, in command prompt. eg. C:/Users/Username>) do
then do
If you have a problem with a certain package stalling the upgrade (numpy sometimes), just go to the directory ($), comment out the name (add a # before it) and run the upgrade again. You can later uncomment that section back. |
|||||||||||||||||||||
|
|
Windows version after consulting excellent documentation for
|
|||||||||||||||||||||
|
|
You can just print the packages that are outdated
|
|||||||||
|
|
The following one-liner might prove of help:
If you need more "fine grained" control over what is omitted and what raises an error you should not add the
Here is a working example:
|
|||||||||||||
|
|
This option seems to me more straightforward and readable:
( And this version allows for the suppression of warning message from
( This could also be used to tackle the coming default
|
|||||||||||||
|
|
This seems more concise.
Explanation:
In So the above lines becomes:
then pass them to
|
|||||||||||||
|
|
From https://github.com/cakebread/yolk :
however you need to get yolk first:
|
|||||
|
|
One-liner version of @Ramana's answer.
` |
|||||||||
|
|
I had the same problem with upgrading. Thing is, i never upgrade all packages. I upgrade only what i need, because project may break. Because there was no easy way for upgrading package by package, and updating the requirements.txt file, i wrote this pip-upgrader which also updates the versions in your Installation
Usage Activate your virtualenv (important, because it will also install the new versions of upgraded packages in current virtualenv).
Advanced usage If the requirements are placed in a non-standard location, send them as arguments:
If you already know what package you want to upgrade, simply send them as arguments:
If you need to upgrade to pre-release / post-release version, add Full disclosure: I wrote this package. |
|||||||||||||
|
|
More Robust Solution For pip3 use this:
For pip, just remove the 3s as such:
OSX Oddity OSX, as of July 2017, ships with a very old version of sed (a dozen years old). To get extended regular expressions, use -E instead of -r in the solution above. Solving Issues with Popular Solutions This solution is well designed and tested1, whereas there are problems with even the most popular solutions.
The above command uses the simplest and most portable pip syntax in combination with sed and sh to overcome these issues completely. Details of sed operation can be scrutinized with the commented version2. Details [1] Tested and regularly used in a Linux 4.8.16-200.fc24.x86_64 cluster and tested on five other Linux/Unix flavors. It also runs on Cygwin64 installed on Windows 10. Testing on iOS is needed. [2] To see the anatomy of the command more clearly, this is the exact equivalent of the above pip3 command with comments:
[3] Upgrading a Python or PIP component that is also used in the upgrading of a Python or PIP component can be a potential cause of a deadlock or package database corruption. |
|||||||||||||||||||||
|
|
when using a virtualenv and if you just want to upgrade packages added to your virtualenv, you may want to do:
|
|||
|
|
|
You can try this :
|
|||||
|
|
The rather amazing yolk makes this easy.
For more info on yolk: https://pypi.python.org/pypi/yolk/0.4.3 It can do lots of things you'll probably find useful. |
|||||||||||||
|
|
@Ramana's worked the best for me, of those here, but I had to add a few catches:
The @endolith: I was hoping for an easy |
|||||
|
|
Sent through a pull-request to the pip folk; in the meantime use this pip library solution I wrote:
|
|||||
|
|
This seemed to work for me...
I used |
|||
|
|
|
Windows Powershell solution
|
|||
|
|
|
My script:
|
|||
|
|
|
The simplest and fastest solution that I found in the pip issue discussion is:
|
||||
|
|
|
Here is my variation on rbp's answer, which bypasses "editable" and development distributions. It shares two flaws of the original: it re-downloads and reinstalls unnecessarily; and an error on one package will prevent the upgrade of every package after that.
Related bug reports, a bit disjointed after the migration from bitbucket: |
||||
|
|
|
I have tried the code of Ramana and I found out on Ubuntu you have to write
|
||||
|
|
|
here is another way of doing with a script in python
|
|||
|
|
|
I've been using pur lately. It's simple and to the point. It updates your
|
|||
|
|
|
Isn't this more effective?
|
|||||||||||||||||||||
|
|
Here is a scripts that only updates the outdated packages.
|
||||
|
|
or even:
Works fast as it is not constantly launching a shell. I would love to find the time to get this actually using the list outdated to speed things up still more. |
|||||||||
|
|
Here is my variation:
|
|||
|
|
pip freeze(likebundle installornpm shrinkwrap). Best to save a copy of that before tinkering. – Colonel Panic May 22 '13 at 13:01pipinstallation up, when you upgraderequests. The error message iscannot import name IncompleteRead. – Paul Rooney Jun 6 '16 at 5:09