Mac Python3 批量升级 pip 所有包

Mac Python3 批量升级 pip 所有包 代码如下:

import subprocess as sbp
import pip

pkgs = eval(str(sbp.run("pip3 list -o --format=json", shell=True,
                       stdout=sbp.PIPE).stdout, encoding='utf-8'))
jd=1
for pkg in pkgs:
   sbp.run("pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade " + pkg['name'], shell=True)
   print('\n【{}】'.format(jd)," pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade " + pkg['name'],'\n')
   jd+=1