-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
When trying to run cloudbase-init using Python 3.12, it errors out ModuleNotFoundError: No module named 'imp'. The 'imp' module was replaced with similar functionality from module importlib. These two implementations are equivalent: ```python import imp import os import site wmi_path = None for packages_path in site.getsitepackages(): path = os.path.join(packages_path, "wmi.py") if os.path.isfile(path): wmi_path = path break wmi_module_name = "wmi" wmi_module = imp.load_source(wmi_module_name, wmi_path) ``` ```python import importlib.util import os import site wmi_path = None for packages_path in site.getsitepackages(): path = os.path.join(packages_path, "wmi.py") if os.path.isfile(path): wmi_path = path break wmi_module_name = "wmi" wmi_module_spec = importlib.util.spec_from_file_location(wmi_module_name, wmi_path) wmi_module = importlib.util.module_from_spec(wmi_module_spec) wmi_module_spec.loader.exec_module(wmi_module) ``` Fixes: #139 Change-Id: I6490c6d9922efea26ab8d167a0d6e41ce34d6c2c Signed-off-by: Adrian Vladu <[email protected]>
- Loading branch information
Showing
4 changed files
with
21 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters