Cold-Blooded Cold-Blooded - 8 months ago 79
Python Question

convert python programme to windows executable

i m trying to create windows executable from python program which has GUI .
i m using following script

from distutils.core import setup
import py2exe


it gives following error

Warning (from warnings module):
File "C:\Python27\lib\distutils\", line 267
UserWarning: Unknown distribution option: 'console'

Traceback (most recent call last):
File "E:\my python\", line 3, in <module>
import py2exe
File "E:\my python\", line 5, in <module>
File "C:\Python27\lib\distutils\", line 140, in setup
raise SystemExit, gen_usage(dist.script_name) + "\nerror: %s" % msg
SystemExit: usage: [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: --help [cmd1 cmd2 ...]
or: --help-commands
or: cmd --help

error: no commands supplied

i can't understand why to need for supplying command as it is GUI based application but it worked fine first time and then it gives above error.
please help..........

Answer Source

The problem is that you are compiling this script from the Python IDLE. This is not how it is done with py2exe. If you have used Disutils before, you might have seen this:

python install.

And same is the case of py2exe, you run it from the command line and not the IDLE. So open up cmd and then issue the command:

python py2exe

Here is your script file.

This is better explained in the tutorial.