Pyinstaller & AutoHotkey.exe
See original GitHub issueCurrently, when running a script compiled with Pyinstaller as single file, either Autohotkey itself or ahk-binary pip package needs to be installed. However, if the same .exe is run on a machine lacking either of these, the ahk.script.ExecutableNotFoundError
appears, noting that AutoHotkey.exe could not be located.
As known, for Pyinstaller the AHK package data has to be added manually, but doing something like --add-data "C:\Program Files\Python\Lib\site-packages\ahk_binary";ahk_binary
still results in the same error. The size of a compiled .exe (using --onefile
parameter) does, however, seem to increase by a couple of megabytes – maybe AutoHotkey.exe gets added, but is not found by the AHK part of the script when run.
What is the correct way to include the whole of ahk-binary or at least AutoHotkey.exe (if only that is needed) when compiling with Pyinstaller as single file, so that Autohotkey doesn’t need to be installed on the target machine?
Issue Analytics
- State:
- Created 10 months ago
- Comments:5 (2 by maintainers)
And these templates are essential for correct operation? Do agree regarding a cleaner look, but that is also less pedagogical: for someone unfamiliar with how Pyinstaller works, a search for
_MEIPASS
immediately (literally the first hit) leads to answers of what that line does in the code – not so much for the general__file__
. As my issue was solved, you may close this ticket if suitable.As I understand it, using
__file__
is now supported for apps frozen with pyinstaller, which may be cleaner than_MEIPASS
.The
--add-data
bit is needed because this project relies on non-python data files (AHK script templates). Under normal conditions, users don’t have to worry about this because the data files are bundled with the package when you install it withpip
. However, pyinstaller does not automatically include these files.I’m thinking about removing the need for that in a future release so pyinstaller integration is less painful.