Last active
October 11, 2016 02:16
-
-
Save hxer/876dfe78848a4534cb0f to your computer and use it in GitHub Desktop.
一键升级python 第三方包
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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