How to use pip to update all installed packages in python

黄舟
Release: 2017-05-21 14:07:56
Original
3371 people have browsed it

下面小编就为的带来一篇python通过pip更新所有已安装的包实现方法。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧

较新的pip已经支持list --outdated了,所以记录一下新的方法:

pip list --outdated --format=legacy |awk '{print $1}' |xargs sudo -H pip install -U
pip3 list --outdated --format=legacy |awk '{print $1}' |xargs sudo -H pip3 install -U
Copy after login

format有两个选项,一个是legacy,一个是columns。后者会带一个表头:

Package        Version Latest Type
-------------- ------- ------ -----

因此选择用legacy的格式,用awk取第一列就好了。

另外,网上很多方法都是在root下操作或者直接sudo不带-H的,这会在一些机器上出现问题。推荐用sudo -H,具体效果请自行查看man手册。

The above is the detailed content of How to use pip to update all installed packages in python. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template