python一键更新库包

将pip 升到 10.0.0 版本后,以前一直能用的一键升级所有库的脚本不好用了

# -*- coding: utf-8 -*-
import pip
# pip V10.0.0以上版本需要导入下面的包
from pip._internal.utils.misc import get_installed_distributions
from subprocess import call
from time import sleep
 
for dist in get_installed_distributions():
    call("pip install --upgrade " + dist.project_name, shell=True)

亲测好用!

猜你喜欢

转载自blog.csdn.net/Lxy_Python/article/details/81711988