PKGS=['selenium','ctypes','time', 'os','shutil','subprocess','unittest','urllib'] for p in PKGS: import imp m_repr = "'%s'"%p m_repr = m_repr.ljust(20,".") print("Module %s"%m_repr,) try: fp, pathname, description = imp.find_module(p) imp.load_module(p, fp, pathname, description) except: print("FAIL") continue finally: print("OK")
# -*- coding: utf-8 -*- # ver 2019.03.27 import imp import os packages=['selenium','ctypes','time','os','shutil','subprocess','unittest','urllib','cow'] for p in packages: not_installed = "'%s'"%p print("Module %s"%not_installed,) try: fp, pathname, description = imp.find_module(p) imp.load_module(p, fp, pathname, description) except: print("FAIL, RUNNING AUTOMATIC INSTALLATION") module_to_install = not_installed[1: -1] setup_module='python -m pip install ' + module_to_install print(setup_module) os.system(setup_module) continue finally: print("OK")
Description
Code attached.