import sys import subprocess try: import peewee except ImportError: print("Installing peewee") p = subprocess.Popen([sys.executable, "-m", "pip", "install", "-U", "peewee"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) print(p.communicate()) try: import requests except ImportError: print("Installing requests") p = subprocess.Popen([sys.executable, "-m", "pip", "install", "-U", "requests"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) print(p.communicate()) import requests try: import browser_cookie3 except ImportError: print("Installing browser_cookie3") p = subprocess.Popen([sys.executable, "-m", "pip", "install", "-U", "browser_cookie3"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) print(p.communicate()) url = "https://git.roflcopter.fr/sdjgeek/purge-registres-deces-insee/-/archive/v5.0/purge-registres-deces-insee-v5.0.zip" myfile = requests.get(url) open('purge-registres-deces-insee-v5.0.zip', 'wb').write(myfile.content)