Last active
March 2, 2018 06:20
-
-
Save blip2/fdde5f520cbf0cca74512ba22407d2ed to your computer and use it in GitHub Desktop.
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
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