Question:
How do I save a python program in a format anyone can open?
2010-10-16 11:03:25 UTC
Is there a format I can save my python program so anyone on any computer can open even if they don't have python? I know .exe wouldn't work, so... help?
Three answers:
siamese_scythe
2010-10-16 11:23:24 UTC
If your program requires minimal interaction and runs for less than 10 seconds (and falls within a few other restrictions), then you can paste the source to http://ideone.com and pass on the link for other people to run it online. I understand this is a special circumstance, but maybe your program happens to fit into that category.
fallibledragon
2010-10-16 18:04:17 UTC
Not really. You might be able to find a cross-platform installer toolkit. Python has a cross-platform installer system built-in, the egg format, but I don't like it much. I mean, you should be able to find something more GUI-based.



Your best bet is probably to create a tar.gz file of the .py (or .pyw) file(s) for Linux and other unix-like systems, and a .exe for windows. Mac is enough like Unix that the .py files should work there too, but you might want to make it easier for mac users.



Actually, on Linux, your best bet is to talk to a distro maintainer, and get them to help you package it for their distro. That way, it would be included in the CDs and installers the Linux distro itself makes: a bit like your program coming with the Windows CD ;)



Update: Since you've said you understand very little of the above, I'll simplify.... This is hard. Making things work cross-platform is rarely easy, and python isn't IDEAL for it, although it's better than a lot of languages. Java is slightly better at this.



If you're not too worried about making it look professional, then the simplest way is to make it a single .pyw file, and just tell them to install python before running it. If you want a GUI, use python's built-in TK graphics library; it'll work cross-platform. This way, users can just double-click your .pyw file, and a program should pop up. It'll work with .py files too, except it'll be terminal-based (not graphics, just text).



If this is still too difficult, you'll need to just stick to more basic things for a while.
2010-10-16 18:34:49 UTC
Save the source as a text file. No one can run it without Python, but they can open it and look at it.



If you want them to be able to run it without Python, use py2exe http://www.py2exe.org/ to compile it to an exe.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...