Skip to content

Instantly share code, notes, and snippets.

@hxer
Last active October 11, 2016 02:16
Show Gist options
  • Save hxer/876dfe78848a4534cb0f to your computer and use it in GitHub Desktop.
Save hxer/876dfe78848a4534cb0f to your computer and use it in GitHub Desktop.
一键升级python 第三方包
# -*- coding: utf-8 -*-
# auto upgrade python package
# need root privilige
"""
import pip
from subprocess import call
for dist in pip.get_installed_distributions():
call("pip install --upgrade " + dist.project_name, shell=True)
"""
import os
import pip
# lower case
noupgrade = ["django"]
for pkg in pip.get_installed_distributions():
pkg_name = pkg.project_name
if pkg_name.lower() not in noupgrade:
os.system("pip install --upgrade {pkg}".format(pkg=pkg_name))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment