查看系統裏過時的python庫,能夠用pip命令node
[root@vnode33 sim-enb-sgi]# pip list Package Version ---------------- --------- appdirs 1.4.2 attrs 16.3.0 Automat 0.5.0 bcrypt 3.1.3 certifi 2017.4.17 ...#列出全部安裝的庫
pip list --outdated # 列出全部過時的庫 Package Version Latest Type ---------------- --------- ---------- ----- appdirs 1.4.2 1.4.3 wheel attrs 16.3.0 18.2.0 wheel Automat 0.5.0 0.7.0 wheel bcrypt 3.1.3 3.1.6 wheel certifi 2017.4.17 2018.11.29 wheel cffi 1.10.0 1.11.5 wheel
pip install --upgrade 庫名
但此命令不支持全局所有庫升級。python
在stackoverflow上有人提供了批量更新的辦法,一個循環就搞定(注意--upgrade後面的空格)shell
import pip from subprocess import call for dist in pip.get_installed_distributions(): call("pip3 install --upgrade " + dist.project_name, shell=True)
pip若是升級到10.0之後須要用如下方法批量更新:app
from subprocess import call from pip._internal.utils.misc import get_installed_distributions
for dist in get_installed_distributions(): call("pip3 install --upgrade " + dist.project_name, shell=True)