Skip to content

Instantly share code, notes, and snippets.

@makiftasova
Created August 7, 2016 04:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save makiftasova/dd3b987b140487d5440ef932e0134056 to your computer and use it in GitHub Desktop.
Save makiftasova/dd3b987b140487d5440ef932e0134056 to your computer and use it in GitHub Desktop.
A Python script to upgrade all installed pip packages.
#!/usr/bin/env python3
"""pip-upgrade.py: A Python script to upgrade all installed pip packages."""
__author__ = "Mehmet Akif TAŞOVA"
__email__ = "makiftasova@gmail.com"
__license__ = "GPLv3+"
__version__ = "1.0.0"
import os, sys, pip
from subprocess import call
def check_root() :
euid = os.geteuid()
if euid != 0:
print("Script not started as root. Running sudo..")
args = ['sudo', sys.executable] + sys.argv + [os.environ]
os.execlpe('sudo', *args)
def main():
check_root()
for dist in pip.get_installed_distributions():
call("pip install --upgrade " + dist.project_name, shell=True)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment