{"id":408,"date":"2017-09-01T11:50:08","date_gmt":"2017-09-01T11:50:08","guid":{"rendered":"http:\/\/buklijas.info\/blog\/?p=408"},"modified":"2017-07-23T16:00:55","modified_gmt":"2017-07-23T16:00:55","slug":"make-standalone-executable-from-python-code-with-pyinstaller","status":"publish","type":"post","link":"http:\/\/buklijas.info\/blog\/2017\/09\/01\/make-standalone-executable-from-python-code-with-pyinstaller\/","title":{"rendered":"Make standalone executable from Python code with PyInstaller"},"content":{"rendered":"

Published on:<\/strong> 01.09.2017<\/p>\n

I wanted to create single file that person could run on Windows machine, from my Pythone code.<\/p>\n

After some investigation I found PyInstaller<\/a> and 1 hour later I had my EXE file from Python code.<\/p>\n

Process for generating EXE files from Python code with PyInstaller<\/a> was quite easy, at least from my experience.<\/p>\n

I have used it on Windows 7 64-bit and had no problems.<\/p>\n

My program was one file script with 300 line and dependencies to docopt<\/a> and pyautogui<\/a>.<\/p>\n

Steps for generating exe file with PyInstaller<\/h3>\n

This will install PyInstaller
\npip install pyinstaller<\/code><\/p>\n

This will generate script.exe in dist directory
\npyinstaller --onefile script.py<\/code><\/p>\n

After this you have your EXE program.<\/p>\n

How PyInstaller is working<\/h3>\n

Here I have used --onefile<\/code> option for PyInstaller what will make one file EXE program.<\/p>\n

If you just use pyinstaller script.py, with out --onefile<\/code> option, than in dist folder you will get folder script with EXE file and all additional files for your EXE file to work.<\/p>\n

If you use --onefile<\/code> option, then your one file EXE program need every time to uncompresses all files every time when it starts.<\/p>\n

Uncompression is described in details in official documentation<\/a>, temporary directory for uncompression in Windows is %TEMP%<\/a>.<\/p>\n

Some other solutions:
\n
http:\/\/nsis.sourceforge.net\/Main_Page<\/a>
\n
http:\/\/nuitka.net\/<\/a>
\n
https:\/\/pypi.python.org\/pypi\/pynsist<\/a>
\n
https:\/\/cx-freeze.readthedocs.io\/en\/latest\/<\/a>
\n
http:\/\/www.py2exe.org\/<\/a><\/p>\n

Comparison of some others solutions<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"

Published on: 01.09.2017 I wanted to create single file that person could run on Windows machine, from my Pythone code. After some investigation I found PyInstaller and 1 hour later I had my EXE file from Python code. Process for generating EXE files from Python code with PyInstaller was quite easy, at least from my […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false},"categories":[27],"tags":[4],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"yoast_head":"\nMake standalone executable from Python code with PyInstaller - Sasa Buklijas<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/buklijas.info\/blog\/2017\/09\/01\/make-standalone-executable-from-python-code-with-pyinstaller\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Make standalone executable from Python code with PyInstaller - Sasa Buklijas\" \/>\n<meta property=\"og:description\" content=\"Published on: 01.09.2017 I wanted to create single file that person could run on Windows machine, from my Pythone code. After some investigation I found PyInstaller and 1 hour later I had my EXE file from Python code. Process for generating EXE files from Python code with PyInstaller was quite easy, at least from my […]\" \/>\n<meta property=\"og:url\" content=\"http:\/\/buklijas.info\/blog\/2017\/09\/01\/make-standalone-executable-from-python-code-with-pyinstaller\/\" \/>\n<meta property=\"og:site_name\" content=\"Sasa Buklijas\" \/>\n<meta property=\"article:published_time\" content=\"2017-09-01T11:50:08+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-07-23T16:00:55+00:00\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\">\n\t<meta name=\"twitter:data1\" content=\"Sasa Buklijas\">\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\">\n\t<meta name=\"twitter:data2\" content=\"1 minute\">\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"http:\/\/buklijas.info\/blog\/#website\",\"url\":\"http:\/\/buklijas.info\/blog\/\",\"name\":\"Sasa Buklijas\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"http:\/\/buklijas.info\/blog\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"http:\/\/buklijas.info\/blog\/2017\/09\/01\/make-standalone-executable-from-python-code-with-pyinstaller\/#webpage\",\"url\":\"http:\/\/buklijas.info\/blog\/2017\/09\/01\/make-standalone-executable-from-python-code-with-pyinstaller\/\",\"name\":\"Make standalone executable from Python code with PyInstaller - Sasa Buklijas\",\"isPartOf\":{\"@id\":\"http:\/\/buklijas.info\/blog\/#website\"},\"datePublished\":\"2017-09-01T11:50:08+00:00\",\"dateModified\":\"2017-07-23T16:00:55+00:00\",\"author\":{\"@id\":\"http:\/\/buklijas.info\/blog\/#\/schema\/person\/780025d597f1c5df3cc156eaffc8c561\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/buklijas.info\/blog\/2017\/09\/01\/make-standalone-executable-from-python-code-with-pyinstaller\/\"]}]},{\"@type\":\"Person\",\"@id\":\"http:\/\/buklijas.info\/blog\/#\/schema\/person\/780025d597f1c5df3cc156eaffc8c561\",\"name\":\"Sasa Buklijas\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"http:\/\/buklijas.info\/blog\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"http:\/\/0.gravatar.com\/avatar\/9f6f7de5a4882517ca0e4a8ebd607925?s=96&d=mm&r=g\",\"caption\":\"Sasa Buklijas\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p5YHGV-6A","_links":{"self":[{"href":"http:\/\/buklijas.info\/blog\/wp-json\/wp\/v2\/posts\/408"}],"collection":[{"href":"http:\/\/buklijas.info\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/buklijas.info\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/buklijas.info\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/buklijas.info\/blog\/wp-json\/wp\/v2\/comments?post=408"}],"version-history":[{"count":10,"href":"http:\/\/buklijas.info\/blog\/wp-json\/wp\/v2\/posts\/408\/revisions"}],"predecessor-version":[{"id":445,"href":"http:\/\/buklijas.info\/blog\/wp-json\/wp\/v2\/posts\/408\/revisions\/445"}],"wp:attachment":[{"href":"http:\/\/buklijas.info\/blog\/wp-json\/wp\/v2\/media?parent=408"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/buklijas.info\/blog\/wp-json\/wp\/v2\/categories?post=408"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/buklijas.info\/blog\/wp-json\/wp\/v2\/tags?post=408"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}