Round 1 was nearly 18 months ago (PyInstaller1.2) and enabled me to successfully deploy a GUI application as a folder (although the XP button styles weren’t quite right – solved below).
Round 2 lasted about 8 hours and involved pyInstaller 1.3 on XP with python 2.5, wxPython 18.104.22.168, and win32com 2.1.0. If I’d had these tips at the beginning it would have taken 20 minutes max 🙁 :
- Don’t name any folders “python”. It shouldn’t matter and usually it doesn’t but sometimes it does. Use mypy or something similar instead. That could have saved 6 hours right there 😉 . If a module was referred to as python.msaccess, for example, the python part would be treated as a module and expected to have an __init__ method. NB everything worked fine except when it was processed into an executable by pyinstaller.
- When testing the build process of a spec file, set console to True (or 1) and debug to True (or 1).
- When running the build process from a batch file, add the command
as the final line. Then you can see all the errors, if any, and have a chance at fixing them. Can also add something like raw_input(“Hit Enter to continue”) at the end of Config.py etc to ensure files like upx are configured successfully.
- To identify problems with the executable, run it from a batch file, and include pause as the final command on its own line. NB make the exe with debug=True and Console=True for these steps (revert when issues fixed).
- Set console=False (or 0) so that XP buttons look more attractive than the older, rectangular form.
XP and wxPython and XP buttons etc
- If doing a single file executable, remember to add a.binaries after a.scripts
and set exclude_binaries=False
- It really is quite easy to edit a spec file – it is just python after all.
- Scripts should be without comma separation and with single backslashes in the makespec process (Batch file), and with commas and double backslashes in the python spec file.
- Icon images etc can be kept in the same folder as the executable for ease of portability. Inside the script they should not have an absolute path.
- Start with a simple HelloWorld test as per the very helpful http://www.thescripts.com/forum/thread579554.html to check all systems are working before tackling a more complex, real-world example which will require getting down and dirty with the spec document.
- python “…Build.py” “…..” won’t work on my system – need “C:\Python25\python.exe” “etc …”
There is excellent documentation available at PyInstaller Manual
UPDATE: got a mysterious error on a script that worked well until it was processed by pyinstaller. Without all the gruesome details, it was because I had the wxPython application set to not redirect its output AND I had some print statements tucked away in some code. At some point (when the printed output reached 4096 bytes?) up popped an [Error 9] Bad file descriptor error. In future, diagnose by making an output.txt file and setting redirect to true. What is in the output file?
UPDATE: Use the -w parameter to skip the DOS window during execution.