{"id":19,"date":"2008-02-16T16:08:19","date_gmt":"2008-02-16T04:08:19","guid":{"rendered":"http:\/\/p-s.co.nz\/wordpress\/?p=19"},"modified":"2011-06-20T15:51:59","modified_gmt":"2011-06-20T03:51:59","slug":"pyinstaller-round-2","status":"publish","type":"post","link":"http:\/\/p-s.co.nz\/wordpress\/pyinstaller-round-2\/","title":{"rendered":"PyInstaller Round 2"},"content":{"rendered":"<p>Round 1 was nearly 18 months ago (<a href=\"http:\/\/p-s.co.nz\/wordpress\/?p=3\">PyInstaller1.2<\/a>) and enabled me to successfully deploy a GUI application as a folder (although the XP button styles weren&#8217;t quite right &#8211; solved below).<\/p>\n<p>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&#8217;d had these tips at the beginning it would have taken 20 minutes max \ud83d\ude41 :<\/p>\n<ol>\n<li>Don&#8217;t name any folders &#8220;python&#8221;.  It shouldn&#8217;t matter and usually it doesn&#8217;t but sometimes it does.  Use mypy or something similar instead.  That could have saved 6 hours right there \ud83d\ude09 .  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.<\/li>\n<li>When testing the build process of a spec file, set console to True (or 1) and debug to True (or 1).<\/li>\n<li>When running the build process from a batch file, add the command <br \/>\npause <br \/>\nas 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(&#8220;Hit Enter to continue&#8221;) at the end of Config.py etc to ensure files like upx are configured successfully.<\/li>\n<li>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).<\/li>\n<li>Set console=False (or 0) so that XP buttons look more attractive than the older, rectangular form.<br \/>\n<img decoding=\"async\" src=\"http:\/\/www.p-s.co.nz\/images\/round_buttons.jpg\" alt=\"Rounded XP buttons\" \/><br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;vs<br \/>\n<img decoding=\"async\" src=\"http:\/\/www.p-s.co.nz\/images\/rect_buttons.jpg\" alt=\"Rectangular XP buttons\" \/><br \/>\n<a href=\"http:\/\/groups.google.com\/group\/PyInstaller\/browse_thread\/thread\/399773943478b5e5\/69add69a59701c64?hl=en&#038;lnk=gst&#038;q=wxpython#69add69a59701c64\"><br \/>\nXP and wxPython and XP buttons etc<\/a><\/li>\n<li>If doing a single file executable, remember to add a.binaries after a.scripts<br \/>\na.scripts, a.binaries,<br \/>\nand set exclude_binaries=False<\/li>\n<li>It really is quite easy to edit a spec file &#8211; it is just python after all.<\/li>\n<li>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.<\/li>\n<li>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.<\/li>\n<li>Start with a simple HelloWorld test as per the very helpful <a href=\"http:\/\/www.thescripts.com\/forum\/thread579554.html\">http:\/\/www.thescripts.com\/forum\/thread579554.html<\/a> 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.<\/li>\n<li>python &#8220;&#8230;Build.py&#8221; &#8220;&#8230;..&#8221; won&#8217;t work on my system &#8211; need &#8220;C:\\Python25\\python.exe&#8221; &#8220;etc &#8230;&#8221;<\/li>\n<\/ol>\n<p>There is excellent documentation available at <a href=\"http:\/\/pyinstaller.hpcf.upr.edu\/docs\/Manual_v1.1.html\">PyInstaller Manual<\/a><\/p>\n<p>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?<\/p>\n<p>UPDATE: Use the -w parameter to skip the DOS window during execution.<\/p>\n<p>UPDATE: <a href=\"http:\/\/p-s.co.nz\/wordpress\/?p=717\">Pyinstaller 1.5 with Python 2.6 (Round 3)<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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&#8217;t quite right &#8211; solved below). Round 2 lasted about 8 hours and involved pyInstaller &hellip; <a href=\"http:\/\/p-s.co.nz\/wordpress\/pyinstaller-round-2\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,3],"tags":[],"class_list":["post-19","post","type-post","status-publish","format-standard","hentry","category-open-source","category-python"],"_links":{"self":[{"href":"http:\/\/p-s.co.nz\/wordpress\/wp-json\/wp\/v2\/posts\/19"}],"collection":[{"href":"http:\/\/p-s.co.nz\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/p-s.co.nz\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/p-s.co.nz\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/p-s.co.nz\/wordpress\/wp-json\/wp\/v2\/comments?post=19"}],"version-history":[{"count":3,"href":"http:\/\/p-s.co.nz\/wordpress\/wp-json\/wp\/v2\/posts\/19\/revisions"}],"predecessor-version":[{"id":695,"href":"http:\/\/p-s.co.nz\/wordpress\/wp-json\/wp\/v2\/posts\/19\/revisions\/695"}],"wp:attachment":[{"href":"http:\/\/p-s.co.nz\/wordpress\/wp-json\/wp\/v2\/media?parent=19"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/p-s.co.nz\/wordpress\/wp-json\/wp\/v2\/categories?post=19"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/p-s.co.nz\/wordpress\/wp-json\/wp\/v2\/tags?post=19"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}