[Tutor] py2exe

Reed L. O'Brien reed at intersiege.com
Sat Jul 9 05:03:37 CEST 2005

D. Hartley wrote:

>Hello everyone, and I apologize in advance if anyone gets this message twice.
>I am trying to figure out how to use py2exe. I've created a game and
>sent it to friends before, and had to have them install python,
>pygame, and livewires in order to play it, which, as you can imagine,
>is a royal pain.  So the idea of a windows executable sounds just
>I downloaded the package and read through some of the samples.  They
>didnt make a *whole* lot of sense, and I couldn't get them to work, so
>I googled for some more beginner-friendly tutorials, and found one
>basic sort of 'overview' here
>http://www.free2code.net/plugins/articles/read.php?id=395 and another
>tutorial by Pete Shinners here:
>http://www.pygame.org/docs/tut/Executable.html .
>I was very excited to see the later, since the chimp pygame tutorial
>actually made sense to me as a beginner, and I hoped I'd be able to
>follow this one as easily.
>Ah, but alas...
>I modified the setup.py file to match the details of my game (as best
>I can imagine: I don't know what "optimize = 2                    #0,
>1, or 2; like -O and -OO" means, so I just left it as his sample had
>it, and I'm not sure if I put in all of the module names it will need
>specified, but it looks as if its supposed to give me an error if it
>can't find them).  But then the tutorial says "simply run this script
>and it will do all the work. The final executable and DLLs will be
>placed inside a project directory, which will be inside a directory
>named "dist". "  I tried running it by doubleclicking, and it just
>closed out, so I tried it with IDLE open and it gave me the following
>error message:
>Traceback (most recent call last):
>  File "Z:\misc\surprise\1\setup.py", line 49, in ?
>    setup(name=project_name, scripts=[script])
>  File "Z:\misc\python\lib\distutils\core.py", line 137, in setup
>    raise SystemExit, gen_usage(dist.script_name) + "\nerror: %s" % msg
>SystemExit: usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2
>[cmd2_opts] ...]
>   or: setup.py --help [cmd1 cmd2 ...]
>   or: setup.py --help-commands
>   or: setup.py cmd --help
>error: option --force not recognized
>..... which has me stymied.  The
>"Z:\misc\python\lib\distutils\core.py" file is not even the setup.py
>file I'm running (which most of you probably already deduced, but
>which still confuses me a little), and I have no idea what that error
>is trying to tell me.  I do know, however, that no "dist" directory
>was created (unless it was put in some really strange place I don't
>know about).  Was there something wonky with my py2exe install, since
>it's giving me an error from a file in my lib? Or am I just trying to
>use py2exe incorrectly?
>If you know why this isnt working, or know of any
>very-beginner-friendly tutorials other than the ones I found on
>google, I would surely appreciate it!
>Tutor maillist  -  Tutor at python.org

If memory serves you don't run it by clicking.  you call it from commandline, something like:

C:\Python24\python.exe script.py py2exe


keyID: 0x0FA09FCE

More information about the Tutor mailing list