Files
2026-06-30 14:14:15 +08:00

17 lines
456 B
Python

from __future__ import annotations
def require_module(module_name: str, install_hint: str):
try:
return __import__(module_name)
except ModuleNotFoundError as exc:
if exc.name == module_name:
raise RuntimeError(
f"Missing dependency '{module_name}'. Install it with: {install_hint}"
) from exc
raise
def require_cv2():
return require_module("cv2", "pip install opencv-python")