Preamble
I've built a Flask app (with Python, obviously) that interacts via ctypes with a DLL that I've coded in C. This works perfectly.
Then I used PyInstaller to package it up, adding --add-binary ..\build\my.dll;build
to the PyInstaller invocation. (I'm using the one-directory approach, not one-file.)
This works fine. The final executable runs perfectly, just like the original Python version.
Problem
The tricky part is that it doesn't work on another PC. It reports:
_main__.PyInstallerImportError: Failed to load dynlib/dll '\\path\\to\\build\\my.dll'. Most probably this dynlib/dll was not found when the application was frozen.
The reported path is correct. And I even asked Python to list the contents of the directory immediately before trying to load the DLL, and it's there.
The (successful) primary PC and the (failing) test PC are both 64-bit Windows, and the DLL is 64-bit.
I'm at a bit of a loss. I've tried using --hidden-exports
too, but I think that's redundant with the explicit --add-binary
. I've tried making it fail on the primary PC by starting a new console and running from there (in case I'd set some paths up but forgotten, or there was something magic in my venv, but it stubbornly works ever time!).
Help me, SO, what have I missed?