直接运行即可
# @Author : bernard
# @Mail : bernard5@qq.com
# @Date : 2021-9-7
# @Version : 1.3
# Open Source in GPLv3
from re import compile
from os import popen, linesep, system
print("正在获取需要升级的包列表,需要网络,可能需要一点时间")
pkgList = popen("pip list -o").readlines()[2:]
print("已获取全部需要升级的包,共", len(pkgList), "个")
pkgRe = compile(r'[a-zA-Z0-9]+[-]*[a-zA-Z0-9]*')
for i in range(len(pkgList)):
pkgList[i] = pkgRe.search(pkgList[i])[0] + linesep
for i in pkgList:
print(i, end='')
cnt = 0
for i in pkgList:
cnt += 1
system("pip install --upgrade " + i)
print("第" + str(cnt) + "个包"+i[:-1]+"升级完成,还剩"+str(len(pkgList)-cnt)+'个')
if cnt:
print("全部升级已完成")
# @Author : bernard
# @Mail : bernard5@qq.com
# @Date : 2021-9-8
# @Version : 1.4
# Open Source in GPLv3
from re import compile
from os import popen, linesep, system
print("正在获取需要升级的包列表,需要网络,可能需要一点时间")
pkgList = popen("pip list -o").readlines()[2:]
print("已获取全部需要升级的包,共", len(pkgList), "个")
pkgRe = compile(r'[a-zA-Z0-9]+[-]*[a-zA-Z0-9]*')
for i in range(len(pkgList)):
pkgList[i] = pkgRe.search(pkgList[i])[0]
for i in pkgList:
print(i)
cnt = 0
for i in pkgList:
cnt += 1
system("pip install --upgrade " + i + linesep)
print("第" + str(cnt) + "个包"+i+"升级完成,还剩"+str(len(pkgList)-cnt)+'个')
if cnt:
print("全部升级已完成")