如何使用pip升级所有Python软件包? [英] How to upgrade all Python packages with pip?

查看:178
本文介绍了如何使用pip升级所有Python软件包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用 pip 一次升级所有Python软件包. ?

注意:存在功能请求可以在官方问题跟踪器上查看.

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

pip list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1  | xargs -n1 pip install -U

注意:为此存在无限的潜在变化.我试图使这个答案简短而简单,但请在评论中提出一些建议!

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!

pip的旧版本中,您可以改用此:

In older version of pip, you can use this instead:

pip freeze --local | grep -v '^\-e' | cut -d = -f 1  | xargs -n1 pip install -U

grep将跳过@jawache建议的可编辑("-e")软件包定义. (是的,您可以将grep + cut替换为sedawkperl或...).

The grep is to skip editable ("-e") package definitions, as suggested by @jawache. (Yes, you could replace grep+cut with sed or awk or perl or...).

xargs-n1标志可防止在更新一个软件包失败时停止所有操作(感谢 @andsens ).

The -n1 flag for xargs prevents stopping everything if updating one package fails (thanks @andsens).

这篇关于如何使用pip升级所有Python软件包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆