diff --git a/src/PIL/Image.py b/src/PIL/Image.py index d435b561720..7c3826d92c5 100644 --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -355,10 +355,11 @@ def init(): if _initialized >= 2: return 0 + parent_name = __name__.rpartition(".")[0] for plugin in _plugins: try: logger.debug("Importing %s", plugin) - __import__(f"PIL.{plugin}", globals(), locals(), []) + __import__(f"{parent_name}.{plugin}", globals(), locals(), []) except ImportError as e: logger.debug("Image: failed to import %s: %s", plugin, e)