How to compile python script to binary executable


I need to convert a Python script to a Windows executable.

I have Python 2.6 installed to python26.

I have created one script and kept it in C:\pythonscript. Inside this folder there are two files and (this file need coversion) code is

from distutils.core import setup
import py2exe


How can I convert to an exe file?

2/22/2018 4:41:15 PM

Or use PyInstaller as an alternative to py2exe. Here is a good starting point. PyInstaller let's you also create executables for linux and mac...

Here is how one could fairly easily use PyInstaller to solve the issue at hand:


From the tool's documentation:

PyInstaller analyzes and:

  • Writes myscript.spec in the same folder as the script.
  • Creates a folder build in the same folder as the script if it does not exist.
  • Writes some log files and working files in the build folder.
  • Creates a folder dist in the same folder as the script if it does not exist.
  • Writes the myscript executable folder in the dist folder.

In the dist folder you find the bundled app you distribute to your users.

7/14/2019 9:35:12 AM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow