PyInstaller Round 2

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 2.8.7.1, and win32com 2.1.0. If I’d had these tips at the beginning it would have taken 20 minutes max 🙁 :

  1. 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.
  2. When testing the build process of a spec file, set console to True (or 1) and debug to True (or 1).
  3. When running the build process from a batch file, add the command
    pause
    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.
  4. 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).
  5. Set console=False (or 0) so that XP buttons look more attractive than the older, rectangular form.
    Rounded XP buttons
                     vs
    Rectangular XP buttons

    XP and wxPython and XP buttons etc
  6. If doing a single file executable, remember to add a.binaries after a.scripts
    a.scripts, a.binaries,
    and set exclude_binaries=False
  7. It really is quite easy to edit a spec file – it is just python after all.
  8. 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.
  9. 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.
  10. 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.
  11. 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.

UPDATE: Pyinstaller 1.5 with Python 2.6 (Round 3)

1 thought on “PyInstaller Round 2

  1. Pingback: pssst … » Pyinstaller 1.5 with Python 2.6 (Round 3)

Comments are closed.