【环境】最新python中一升级所有已安装的包方法

>>> import pip
>>> pip.get_installed_distributions()
[django-ckeditor 5.1.1 (/usr/local/lib/python2.7/dist-packages/django_ckeditor-5.1.1-py2.7.egg), Pillow 2.2.1 (/usr/local/lib/python2.7/dist-packages/Pillow-2.2.1-py2.7-linux-x86_64.egg), six 1.10.0 (/usr/local/lib/python2.7/dist-packages/six-1.10.0-py2.7.egg), django-widget-tweaks 1.4.1 (/usr/local/lib/python2.7/dist-packages/django_widget_tweaks-1.4.1-py2.7.egg), django-simple-captcha 0.5.3 (/usr/local/lib/python2.7/dist-packages/django_simple_captcha-0.5.3-py2.7.egg), django-crispy-forms 1.6.0 (/usr/local/lib/python2.7/dist-packages/django_crispy_forms-1.6.0-py2.7.egg), ssh-import-id 3.21 (/usr/lib/python2.7/dist-packages), chardet 2.0.1 (/usr/lib/python2.7/dist-packages), python-apt 0.9.3.5ubuntu1 (/usr/lib/python2.7/dist-packages), apt-xapian-index 0.45 (/usr/lib/python2.7/dist-packages), python-debian 0.1.21-nmu2ubuntu2 (/usr/lib/python2.7/dist-packages), colorama 0.2.5 (/usr/lib/python2.7/dist-packages), html5lib 0.999 (/usr/lib/python2.7/dist-packages), urllib3 1.7.1 (/usr/lib/python2.7/dist-packages), requests 2.2.1 (/usr/lib/python2.7/dist-packages), virtualenv 1.11.4 (/usr/lib/python2.7/dist-packages), MySQL-python 1.2.5 (/usr/local/lib/python2.7/dist-packages/MySQL_python-1.2.5-py2.7-linux-x86_64.egg), django-reversion 2.0.6 (/usr/local/lib/python2.7/dist-packages/django_reversion-2.0.6-py2.7.egg), django-redis 4.4.4 (/usr/local/lib/python2.7/dist-packages/django_redis-4.4.4-py2.7.egg), redis 2.10.5 (/usr/local/lib/python2.7/dist-packages/redis-2.10.5-py2.7.egg), xadmin 0.6.1 (/usr/local/lib/python2.7/dist-packages/xadmin-0.6.1-py2.7.egg), httplib2 0.9.2 (/usr/local/lib/python2.7/dist-packages/httplib2-0.9.2-py2.7.egg), django-formtools 1.0 (/usr/local/lib/python2.7/dist-packages/django_formtools-1.0-py2.7.egg), qrcode 5.3 (/usr/local/lib/python2.7/dist-packages/qrcode-5.3-py2.7.egg), Django 1.9.9 (/usr/local/lib/python2.7/dist-packages/Django-1.9.9-py2.7.egg), wsgiref 0.1.2 (/usr/lib/python2.7), argparse 1.2.1 (/usr/lib/python2.7), stevedore 1.17.1 (/usr/local/lib/python2.7/dist-packages), pbr 1.10.0 (/usr/local/lib/python2.7/dist-packages), virtualenv-clone 0.2.6 (/usr/local/lib/python2.7/dist-packages), uWSGI 2.0.13.1 (/usr/local/lib/python2.7/dist-packages), virtualenvwrapper 4.7.2 (/usr/local/lib/python2.7/dist-packages)]
import pip
from subprocess import call
for dist in pip.get_installed_distributions(): 
    call("pip install --upgrade " + dist.project_name, shell=True)

你可能感兴趣的:(【环境】最新python中一升级所有已安装的包方法)