I have a python module as a mymodule.dll
, and I would like to load it without having it in sys.path
. I can do this using importlib
:
mymodule = importlib.machinery.ExtensionFileLoader(
"mymodule", r"C:\X\Y\mymodule.dll").load_module()
Now, mymodule.dll
depends on other DLLs, and I have issues when trying to load it. If I put all the DLLs the module depends on next to it e.g.:
C:\X\Y
mymodule.dll
Qt5Core.dll
Then, I can import mymodule.dll
using the above method from anywhere. But if I move Qt5Core.dll
elsewhere, it always fail with:
ImportError: DLL load failed while importing mymodule: The specified module could not be found.
...even if Qt5Core.dll
is in my PATH
(and ctypes.util.find_library
finds it).
Is there a way to load mymodule.dll
without having to copy its dependencies in the same folder?