[Tutor] how do i use p2exe
Dick Moores
rdm at rcblue.com
Sun Nov 14 04:13:19 CET 2004
This is my second attempt to get some help. I'd REALLY like to be able to
use py2exe:
Am I the only one having trouble with this? Here's what I did, and what
happens.
I'm running Win XP and Python 2.3.4.
I installed py2exe from http://starship.python.net/crew/theller/py2exe/ .
I created setup.py. But in order to have it run I changed the 3rd line of
lookdir() to if look.lower() == "y":
I created the batch file, which I named test.bat. I used the line
cd\python23 as is, because that's where my python23 is.
When I run test.bat I get
"Current directory is: C:\Python23
Do you wish to see what's in directory?"
If I answer "y" I'm correctly shown what's in Python23, and asked,
"What is the file you want as an executable? (Type 'quit' to break out of
loop) ?"
I type "weekday.py" a script I have in Python23.
The "DOS" (consol?) window closes immediately.
That's it. No creation of weekday.exe.
Have I done something wrong. Or what?
Thanks, tutors.
Dick Moores
rdm at rcblue.com
At 19:59 11/9/2004, Jacob S. wrote:
>This is what I did.
>I'm using Windows XP, but it would work for any other windows version...
>
>1) Take code below and copy into file named "setup.py".
>
>### Start of Code ###
>from distutils.core import setup
>import py2exe
>import os
>
>
>def lookdir():
> print "Current directory is: %s" % os.getcwd()
> look = raw_input('Do you wish to see what\'s in directory? ')
> if look.lower() in m:
> print "\n".join(os.listdir(os.getcwd()))
>
>def changedir():
> m = ['y','ye','yes','yep','okay','affirmative','sure']
> ask = 'y'
> lookdir()
> while ask not in m:
> di = raw_input('What directory do you want? ')
> os.chdir(di)
> lookdir()
> ask = raw_input('Do you want this directory? ')
>
>changedir()
>listed = []
>while 1:
> ask = raw_input('What is the file you want as an executable? (Type
>\'quit\' to break out of loop) ')
> if ask == 'quit' or ask == 'stop' or ask == '':
> break
> else:
> listed.append(os.path.join(desktop,ask))
>
>setup(console = listed)
>### End of Code ###
>
>2) Take following code and save as a batch file. You will have to change the
>second line to change the directory to your python dir
>
>rem Start of Code
>@echo off
>cd\python23
>start python setup.py py2exe
>rem End of Code
>
>3) Run the batch file. It will ask you which directory the script file is
>in. That would be the file that you're trying to make and executable. Then,
>when you decide which directory it is in, it will ask you the name of the
>file. You type in the name. If you want more than one file, you can type in
>another file name in the next prompt, else you can type in 'quit' or 'stop'
>or just hit enter. When all is done and the shell window closes, you can
>check out the directory that you chose. In that directory, there will be two
>new folders. One is labeled build. That folder is not necessary to run your
>executable and can be deleted. I usually delete it. The other is labeled
>dist. It contains the files needed for your program. Your program will have
>the same name, just with a exe extension instead of a py extension. Send the
>whole folder on to your students, and they can double-click on the exe file,
>and it will run your script as if you double-clicked it in Windows Explorer.
>
>Also, in your code (which I will try to rewrite for fun on my own (no
>offense)) you might try this instead:
>
>print "".join(["\t","\\"*7," ","\\"*4," ","\\"*6," ","\\"*7," ","\\"*2,"
>","\\"*10," ","\\"*2," ","\\"*8,"\n"])
>
>Ignore the underline and blue if it shows up in your email thing.
>This just shows that you can multiply a particular string by an integer to
>copy it.
>
>Hope all this helps,
>Jacob Schmidt
_______________________________________________
Tutor maillist - Tutor at python.org
http://mail.python.org/mailman/listinfo/tutor
More information about the Tutor
mailing list