I’m building an application that requires loading a software specific DLL at runtime. The application is built using Pyinstaller
, but since the DLL must be loaded at runtime (depending on the user’s machine, licensing), I’m unable to bundle the dll when building the application. To load the dll, I’m doing the following:
- Adding the dirpath of the dll to the “PATH” using
os.environ["PATH"] = <dll_dir_path>
- Calling the
ctypes
CDLL
method with the absolute filepath to the DLL withCDLL(dll_filepath, winmode=0)
.
Now, everything runs smoothly when I build the application in my local machine (be it with debug or not debug mode). However, when I build the application using a GH
actions deployment process, I get the following error:
There was an error loading the Sofistik DLL: Failed to load dynlib/dll '<my_dll.dll>. Most likely this dynlib/dll was not found when the application was frozen.'
My local machine is running Windows 11
, and GH
‘s VM is also running Windows
. I suspect there might be some environment variables that are set differently in both machines, which is messing up with the path to the dll somehow…
I’ve tried the suggestion in this post by using ctypes.windll.kernel32.SetDllDirectoryW(None)
but still get the same error.
The dll is from the Sofistik structural analysis software .
Is there anything else I can try to debug or fix this issue? Thank you in advance.