Building an Executable out of a Python Program

Thursday, June 13, 2013

The purpose of this post is to learn how to create a windows executable out of a python program using the Windows operating system.

Note: This method applies to Python version 2.x. For applications written in Python 3.x use cx_Freeze instead.

What we need:

Prerequisites:
  • The Windows operating system, Python, PyInstaller and PyWin32 must be download and/or installed prior to starting this tutorial. These are easy to do, if help is needed simply google around or ask in the comments section.

1. After installing Python2.7 and PyWin32 ensure python is mapped to the PATH.



2. Extract PyInstaller, open up command prompt and CD into the directory.
3. Run 'Python Configure.py'.



4. Run 'Python Makespec.py --onefile <location_of_program>.py'




5.  Run 'Python Build.py <program_name>\<program_name>.spec'



There should now be a directory named after <program_name> (in this case 'hello_world') containing folders named 'build', and 'dist'. The executable will be within the dist directory. Enjoy!

No comments :

Post a Comment