Hi currently, I was debugging an issue where we are importing a module from a full path but importlib.reload will result in issue of "ModuleNotFoundError: spec not found for the module "
if (module_spec := util.spec_from_file_location(self.__module_name, self.__file_name)) is None:
return None
module = util.module_from_spec(module_spec)
module_spec.loader.exec_module(module)
module.__spec__ = module_spec
sys.modules[self.__module_name] = module
return module
We are using the above code for loading the module. self.__file_name has the full path of the module.