Upgrading all packages with pip

2019-01-02 19:07发布

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.

标签: python pip
30条回答
回忆,回不去的记忆
2楼-- · 2019-01-02 19:37

From https://github.com/cakebread/yolk :

$ pip install -U `yolk -U | awk '{print $1}' | uniq`

however you need to get yolk first:

$ sudo pip install -U yolk
查看更多
荒废的爱情
3楼-- · 2019-01-02 19:37

The rather amazing yolk makes this easy.

pip install yolk3k # don't install `yolk`, see https://github.com/cakebread/yolk/issues/35
yolk --upgrade

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.

查看更多
闭嘴吧你
4楼-- · 2019-01-02 19:38

To upgrade all local packages; you could use pip-review:

$ pip install pip-review
$ pip-review --local --interactive

pip-review is a fork of pip-tools. See pip-tools issue mentioned by @knedlsepp. pip-review package works but pip-tools package no longer works.

pip-review works on Windows since version 0.5.

查看更多
情到深处是孤独
5楼-- · 2019-01-02 19:38

Sent through a pull-request to the pip folk; in the meantime use this pip library solution I wrote:

from pip import get_installed_distributions
from pip.commands import install

install_cmd = install.InstallCommand()

options, args = install_cmd.parse_args([package.project_name
                                        for package in
                                        get_installed_distributions()])

options.upgrade = True
install_cmd.run(options, args)  # Chuck this in a try/except and print as wanted
查看更多
只若初见
6楼-- · 2019-01-02 19:39

You can just print the packages that are outdated

pip freeze | cut -d = -f 1 | xargs -n 1 pip search | grep -B2 'LATEST:'
查看更多
怪性笑人.
7楼-- · 2019-01-02 19:39

This seemed to work for me...

pip install -U $(pip list --outdated|awk '{printf $1" "}')

I used printf with a space afterwards to properly separate the package names.

查看更多
登录 后发表回答