Skip to content

Instantly share code, notes, and snippets.

@timdetering
Last active November 12, 2015 18:31
Show Gist options
  • Save timdetering/295c260a735282985660 to your computer and use it in GitHub Desktop.
Save timdetering/295c260a735282985660 to your computer and use it in GitHub Desktop.
#! /usr/bin/python
import pip
import sys
from subprocess import call
def pip_upgrade():
if sys.version_info > (3, 0):
# Python 3 code in this block
pip_cmd = "pip3"
else:
# Python 2 code in this block
pip_cmd = "pip"
for dist in pip.get_installed_distributions():
cmd = "{0} install --upgrade {1}".format(pip_cmd, dist.project_name)
# print(cmd)
call(cmd, shell=True)
if __name__ == '__main__':
pip_upgrade()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment