Skip to content

Instantly share code, notes, and snippets.

@blip2
Last active March 2, 2018 06:20
Show Gist options
  • Save blip2/fdde5f520cbf0cca74512ba22407d2ed to your computer and use it in GitHub Desktop.
Save blip2/fdde5f520cbf0cca74512ba22407d2ed to your computer and use it in GitHub Desktop.
import os
import pip
import ctypes, sys
def is_admin():
try:
return ctypes.windll.shell32.IsUserAnAdmin()
except:
return False
os.chdir(os.path.dirname(os.path.realpath(__file__)))
def install(package):
pip.main(['install', package])
if __name__ == '__main__':
if is_admin():
fh = open('requirements.txt')
for line in fh:
install(line)
fh.close()
else:
ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, "", None, 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment