pip - 批量更新所有库

Python pip本身不支持批量更新功能,但可以借助pip的API编程实现批量更新所有package

pip - 批量更新所有库

1 codes

1
2
3
4
5
6
7
8
# coding: utf-8
import pip
from subprocess import call

call("pip list --outdated", shell=True)

for dist in pip.get_installed_distributions():
call("pip install --upgrade " + dist.project_name, shell=True)