''' pip list --outdated #列出所有过期的库 单个python库更新 pip install --upgrade 库名 批量更新python库 第一种方式,不行采用第二种方式 imprt pip from subprocess import call for dist in pip.get_installed_distributions(): call("pip install --upgrade " + dist.project_name, shell=True) ''' # 第二种方式 # from pip._internal.utils.misc import get_installed_distributions # from subprocess import call # # for dist in get_installed_distributions(): # call("pip install --upgrade " + dist.project_name, shell=True)