{"id":3,"date":"2006-09-09T12:31:27","date_gmt":"2006-09-09T00:31:27","guid":{"rendered":"http:\/\/p-s.co.nz\/blog\/?p=3"},"modified":"2011-06-20T15:57:39","modified_gmt":"2011-06-20T03:57:39","slug":"pyinstaller-and-making-a-python-program-for-deployment","status":"publish","type":"post","link":"http:\/\/p-s.co.nz\/wordpress\/pyinstaller-and-making-a-python-program-for-deployment\/","title":{"rendered":"PyInstaller and making a Python program for deployment"},"content":{"rendered":"<p><a title=\"http:\/\/pyinstaller.hpcf.upr.edu\/cgi-bin\/trac.cgi\" target=\"_blank\" href=\"http:\/\/pyinstaller.hpcf.upr.edu\/cgi-bin\/trac.cgi\">http:\/\/pyinstaller.hpcf.upr.edu\/cgi-bin\/trac.cgi <\/a><\/p>\n<p><span class=\"postbody\">PyInstaller packages Python programs into standard executables, that work on computers without Python installed. It doesn&#8217;t automatically create a subfolder <\/span>structure and put things like images etc in there.  That must remain a manual step.<\/p>\n<p><span class=\"postbody\">The idea is to give someone a zipped up folder which they can unzip somewhere and it will work.  They may not even have python installed, or the same version of python installed.<\/span><\/p>\n<p>0. ********************************************<\/p>\n<p>Install pyinstaller!<\/p>\n<p>1. *********************************************<\/p>\n<p>Run the following:<\/p>\n<pre>\"C:\\Python24\\Libsite-packages\\pyinstaller_1.2\\Makespec.py\"\r\n--name=\"myVersion\"\r\n--onedir\r\n--windowed\r\n--out=\"C:\\Backup\\myVersion\\Package\"\r\n\"C:\\Backup\\myVersion\\myVersionGUI.py\"\r\n\"backup_classes_no_prompts.py\"\r\n\"my_data.py\"\r\n\"myVersion.py\"\r\n\"myVersion_add_package.py\"\r\n\"myVersion_package_details.py\"\r\n\"myVersion_packages_list.py\"<\/pre>\n<p>The series of scripts at the end is what is put into the executable.<\/p>\n<p>&#8211;windowed (Use the Windows subsystem executable, which does not open the console when the program is launched. (Windows only))<\/p>\n<p>(if too long, leave out a file and add it manually into myVersion.spec once made).<\/p>\n<p>The goal is to get:<\/p>\n<pre>a = Analysis([os.path.join(HOMEPATH,'support_mountzlib.py'),\r\nos.path.join(HOMEPATH,'supportuseUnicode.py'),\r\n'C:\\Backup\\myVersion\\myVersionGUI.py',\r\n'C:\\Backup\\myVersion\\backup_classes_no_prompts.py',\r\n'C:\\Backup\\myVersion\\my_data.py',\r\n'C:\\Backup\\myVersion\\myVersion.py',\r\n'C:\\Backup\\myVersion\\myVersion_add_package.py',\r\n'C:\\Backup\\myVersion\\myVersion_package_details.py'],\r\npathex=['C:\\Python24\\Libsite-packages\\pyinstaller_1.2'])\r\npyz = PYZ(a.pure)\r\nexe = EXE(pyz,\r\na.scripts,\r\nexclude_binaries=1,\r\nname='buildmyVersion\/myVersion.exe',\r\ndebug=False,\r\nstrip=False,\r\nupx=False,\r\nconsole=False )\r\ncoll = COLLECT( exe,\r\na.binaries,\r\nstrip=False,\r\nupx=False,\r\nname='distmyVersion')<\/pre>\n<p>This can be manually edited etc.<\/p>\n<p>2. **********************************************<\/p>\n<p>NB all the syntax MUST be checked first (e.g. in DrPython).<\/p>\n<p>Then:<br \/>\n&#8220;C:\\Python24\\Lib\\site-packages\\pyinstaller_1.2\\Build.py&#8221; &#8220;C:\\Backup\\myVersion\\Package\\myVersion.spec&#8221;<br \/>\n3. **********************************************<\/p>\n<p>Then manually add the following to the &#8220;distmyVersion&#8221; folder:<\/p>\n<p>python_logo_only_39.xpm<br \/>\npython_logo_only_16.xpm<\/p>\n<p>UPDATE: version 1.3 came out in Dec 2006.  There is a great article about how to install and use it at: <a href=\"http:\/\/www.thescripts.com\/forum\/thread579554.html\">http:\/\/www.thescripts.com\/forum\/thread579554.html<\/a><\/p>\n<p>UPDATE: <a href=\"http:\/\/p-s.co.nz\/wordpress\/?p=19\">Pyinstaller Round 2<\/a><\/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>http:\/\/pyinstaller.hpcf.upr.edu\/cgi-bin\/trac.cgi PyInstaller packages Python programs into standard executables, that work on computers without Python installed. It doesn&#8217;t automatically create a subfolder structure and put things like images etc in there. That must remain a manual step. The idea is to &hellip; <a href=\"http:\/\/p-s.co.nz\/wordpress\/pyinstaller-and-making-a-python-program-for-deployment\/\">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":[3],"tags":[],"class_list":["post-3","post","type-post","status-publish","format-standard","hentry","category-python"],"_links":{"self":[{"href":"http:\/\/p-s.co.nz\/wordpress\/wp-json\/wp\/v2\/posts\/3"}],"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=3"}],"version-history":[{"count":3,"href":"http:\/\/p-s.co.nz\/wordpress\/wp-json\/wp\/v2\/posts\/3\/revisions"}],"predecessor-version":[{"id":735,"href":"http:\/\/p-s.co.nz\/wordpress\/wp-json\/wp\/v2\/posts\/3\/revisions\/735"}],"wp:attachment":[{"href":"http:\/\/p-s.co.nz\/wordpress\/wp-json\/wp\/v2\/media?parent=3"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/p-s.co.nz\/wordpress\/wp-json\/wp\/v2\/categories?post=3"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/p-s.co.nz\/wordpress\/wp-json\/wp\/v2\/tags?post=3"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}