def install_and_import(package):
"""@brief Imports modules and installs them if they are not."""
import importlib
try:
importlib.import_module(package)
except ImportError:
try:
import pip
except ImportError:
print "no pip"
os.system('python get_pip.py')
finally:
import pip
pip.main(['install', package])
finally:
globals()[package] = importlib.import_module(package)
# these other ones I a am not so sure of. Thus the install function.
评论列表
文章目录