views:

67

answers:

1

A person (a senior citizen who is learning the very basics of computers) asked me to make a program that will save him LOTS of time with a grunt work type of task. I made the script in Python, it's simple, command line, takes input from the user and saves the output to a file and that's it.

My first question is related to the output of the script: It doesn't have to be GUI (I have no GUI dev experience and currently no time now), but I also think that it shouldn't be so simplistic as a TXT file, since the output will be 40,000+ lines long and intended for printing (I know it's a waste of paper and I fought hard for him not to do this, but it's his choice). What file format should I output it to? Maybe an HTML file?

Next, he asked me to burn it into a CD that he can just pop it in his laptop and run it directly and save the output to 'C:'. By the nature of his computing capacity, it has to be as simple as possible, and require the least 'after service.' There's no restriction regarding the size that the whole program occupies in his computer.

I tried creating an EXE of my Python script with PY2EXE but when I execute the .EXE, it creates the output file on the same folder, opens no 'window', asks for no input, and runs FOREVER, with the output file size increasing by 20mb/s! Of course, when I run it on regular python, it runs perfectly fine. I looked over other stackoverflow threads and followed the 'bundle_files':1 parameter but still... I'm using Python2.7, should I try PyInstaller? If yes, could people point me to a good tutorial?

Thanks in advance

+6  A: 

There's a good PyInstaller tutorial here. However, PyInstaller does not (yet) support Python 2.7 (indeed, on Windows, I believe there are problems with 2.6 also).

In your use case I would recommend PortablePython -- Python configured to run (on Windows) from a USB key. You could easily put on the USB key Python in the "portable" version, your script, and a .bat that runs your script. However, PortablePython also does not yet support Python 2.7 (2.6, sure, no problem).

If you live on the bleeding edge -- making for-pay work in a release that's been out for so little time, that it doesn't have a .1 subrelease yet;-) -- it's not surprising that advanced third-party tools such as packagers don't fully support you yet. What 2.7 features (not found in 2.6) are you using, to be worth this hassle to you?

Alex Martelli
Oh you got a point. I actually don't need 2.7 features at ALL I believe, especially since I also never programmed in Python until just two weeks earlier. I just agreed to do this little project as an opportunity to learn some Python and get paid while at it ;)I'm essentially relying on a lot of itertools functions, that doesn't require 2.7, right?Should I just install 2.5 then?PortablePython looks interesting, will it work if it runs on a CD? Or only writable media like pendrive?
chiurox
@chiurox, 2.6 and PortablePython is what I would suggest -- surely it would be just as easy for your customer to stick a USB drive into a USB port, as to stick a CD into its reader (and small USB drives are so cheap these days that you can well afford to give him one for free;-). I don't know if it would work on a r-o medium (easy for you to try, though). 2.6 is mature, solid, and well worth using over 2.5, unless you absolutely have to have the latter. `itertools` is in all versions since 2.3, but better and richer in 2.6 (half a dozen new functions and features wrt 2.5).
Alex Martelli