def ensure_module(module_name: str):
"""
Makes sure that a module is importable.
In case the module cannot be found, print an error and exit.
Args:
module_name: name of the module to look for
"""
try:
importlib.import_module(module_name)
except ModuleNotFoundError:
click.secho(
f'Module not found: {module_name}\n'
f'Install it manually with: "pip install {module_name}"\n'
f'Or install all dependencies with: "pip install -r requirements-dev.txt"',
fg='red', err=True)
exit(-1)
评论列表
文章目录