R. Murray R. Murray - 1 year ago 112
C++ Question

Best way to get Python script as an executable file?

I'm creating an application using Python 3.4.3 and tkinter for a project as this is the language I am strongest and most fluent in. However, for the specification it would make much more sense for the end user to have a compiled application to run. Is there any way to either compile Python (pretty sure there isn't) or a way to get C++, or any other compiled language, to run a Python script? Quite a broad question (sorry) and any hints and tips would be useful.

Answer Source

My understanding is that what you want is to end with a single (Windows ?) executable that you could send to your end users to ease deployment.

It is possible (and easy) for scripts that only use a limited and know set of modules, there is even a nice tool on SourceForge dedicated to it: py2exe (following is extracted from tutorial).

You just prepare a setup.py script (when original script is trivially simple with a command line UI):

from distutils.core import setup
import py2exe


and run python setup.py py2exe

As soon as you are using a GUI and many modules, things can become harder, even if doc lets think that tkinter seems correctly processed.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download