importing modules with unequal module and import name
Affected method
def import_module(module_name, global_name=None, reload=True)
The issue Module not found Exception get's raised even if the module is installed in the site packages.
Steps to reproduce When importing b.e. the module opencv the module name is "opencv-python" while its name to import is "cv2". Dependency(module="opencv-python", package=None, name=cv2).
Expected behavior
globals()[global_name] = importlib.import_module(module_name)
tries to import the module by it's module name, not it's "import name". This can be fixed by writing:
globals()[global_name] = importlib.import_module(global_name)
However this will change the functionality of your add-on.
Thanks for the base! Think it would help others if you implement a way to handle modules which import name are not matching their global name.
Thank you for the report. I will add this to my to-do list, but since I'm currently quite busy this may have to wait for a while.
Unless I'm misunderstanding your reported issue, this is already considered in the design. The module is cv2, but the name of the package is opencv-python. Therefore, the declaration of the depedency should be dependencies = (Dependency(module="cv2", package="opencv-python", name=None),).