不是我原创的代码,忘记从哪抄来的了,挺好用的,四行搞定
#!/usr/bin/env python
# encoding: utf-8
from subprocess import call
from pip._internal.utils.misc import get_installed_distributions
for dist in get_installed_distributions():
call("pip install --upgrade " + dist.project_name, shell=True)