From 1b9398819786c06aa075f379234176671820afee Mon Sep 17 00:00:00 2001 From: YunLiu <55491388+KumoLiu@users.noreply.github.com> Date: Wed, 21 Feb 2024 21:30:25 +0800 Subject: [PATCH] Fix Python 3.12 import AttributeError (#7482) Fixes #7458 ### Description https://github.com/python/cpython/blob/a21c0c7def9a8495f1166d9b434dfc301cb92bff/Lib/importlib/abc.py#L68 ### Types of changes - [x] Non-breaking change (fix or new feature that would not break existing functionality). - [ ] Breaking change (fix or new feature that would cause existing functionality to change). - [ ] New tests added to cover the changes. - [ ] Integration tests passed locally by running `./runtests.sh -f -u --net --coverage`. - [ ] Quick tests passed locally by running `./runtests.sh --quick --unittests --disttests`. - [ ] In-line docstrings updated. - [ ] Documentation updated, tested `make html` command in the `docs/` folder. Signed-off-by: YunLiu <55491388+KumoLiu@users.noreply.github.com> --- monai/utils/module.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/monai/utils/module.py b/monai/utils/module.py index 0dcf22fcd7..5e058c105b 100644 --- a/monai/utils/module.py +++ b/monai/utils/module.py @@ -209,7 +209,7 @@ def load_submodules( if (is_pkg or load_all) and name not in sys.modules and match(exclude_pattern, name) is None: try: mod = import_module(name) - importer.find_module(name).load_module(name) # type: ignore + importer.find_spec(name).loader.load_module(name) # type: ignore submodules.append(mod) except OptionalImportError: pass # could not import the optional deps., they are ignored