Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to 'package' a simple, one-file python script for a person that wants to pay for it?

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

like image 889
chiurox Avatar asked Aug 15 '10 03:08

chiurox


People also ask

How do I share a Python program?

Use the "Share" button in the Editor The PythonAnywhere editor (from the Files tab) gives you the option to share a file -- look for the paperclip icon at the top of the editor. This only works for single files, and people you share with will need a PythonAnywhere account.

How do I create a .PY file?

Create a Python fileIn the Project tool window, select the project root (typically, it is the root node in the project tree), right-click it, and select File | New .... Select the option Python File from the context menu, and then type the new filename. PyCharm creates a new Python file and opens it for editing.


1 Answers

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?

like image 70
Alex Martelli Avatar answered Oct 11 '22 13:10

Alex Martelli