Python app works under Visual Studio but fails as .exe

41 views
Skip to first unread message

David Frager

unread,
Sep 23, 2024, 5:28:38 PM9/23/24
to PyInstaller
I have been using pyinstaller for a while under python 3.6, and recently jumped to 3.9.
i have an application that runs properly under VS, however, after building with pyinstaller version 6.10.0, installed via pip, i get an exception.  What is the best way to isolate the issue?

  File "aapt2\aapt.py", line 109, in get_apk_info
  File "aapt2\aapt.py", line 86, in get_apk_info
Exception: can't get packageinfo
[PYI-21588:ERROR] Failed to execute script 'JetStream_packager' due to unhandled exception!

bwoodsend

unread,
Sep 23, 2024, 6:21:08 PM9/23/24
to PyInstaller

Following the line numbers to the source code is the best you can hope for with custom/uninformative exceptions like this. In this case, the exception is raised if some stdout doesn’t match a certain pattern. That stdout comes from dump() which calls aapt which invokes an aapt2\bin\Windows\aapt2.exe executable but using the rather evil subprocess.getoutput() which has zero error handling. Without that error handling, the the aapt() function doesn’t even notice if aapt2.exe is missing and blindly returns the string Can't recognise '...\aapt2.exe ... as an internal or external command, or batch script..

So tl;dr, you’ll need to make sure that aapt2.exe gets into your application. i.e. Add --collect-datas=aapt2 to your build command.

But I’d get away from this library if I were you. Not only does it have this lack of error handling but it also breaks if the path to your .apk file contains spaces.

Reply all
Reply to author
Forward
0 new messages