6

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
setup(console=['gui.py']) 

it gives following error

Warning (from warnings module):
 File "C:\Python27\lib\distutils\dist.py", line 267
 warnings.warn(msg)
UserWarning: Unknown distribution option: 'console'
Traceback (most recent call last):
 File "E:\my python\py2exe.py", line 3, in <module>
 import py2exe
 File "E:\my python\py2exe.py", line 5, in <module>
 setup(console=['ASUP_finalDone1.py'])
 File "C:\Python27\lib\distutils\core.py", line 140, in setup
 raise SystemExit, gen_usage(dist.script_name) + "\nerror: %s" % msg
SystemExit: usage: py2exe.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
 or: py2exe.py --help [cmd1 cmd2 ...]
 or: py2exe.py --help-commands
 or: py2exe.py 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..........

asked Mar 31, 2011 at 4:28
2
  • How are you invoking this script? Commented Mar 31, 2011 at 4:38
  • i m compiling this script from python IDLE GUI shell.... so then it creates a executable , but it run for first time but not anymore Commented Mar 31, 2011 at 4:41

1 Answer 1

7

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 setup.py 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 setup.py py2exe

Here setup.py is your script file.

This is better explained in the tutorial.

answered Mar 31, 2011 at 4:44
Sign up to request clarification or add additional context in comments.

3 Comments

when i run python setup.py py2exe in cmd it gives python is not recognized command.......
so try full path like: c:\Python27\python.exe d:\project\myproject\main_script.py py2exe
This worked. Great. I have a very simple python script about 40 lines, and it generated two folders, build and dist, total over 300 files and 10MB..... Do I need all these just to run it the little program?

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.