3

Suppose I have a group of people to whom I want to show my python program. I don't want to have to tell them each "Ok, go to the python website, install the interpreter, open IDLE, open my program, press F5, and then it will run". Is there some way I can just send them a file of some format and they can run it easily?

I was thinking in the way of embedding it into Java, but the solutions I've seen for that seem to still require the python interpreter to run it.

P.S. I'm new to python, so I would be extremely grateful if responses aren't too technical and confusing. :)

user1048917
  • 415
  • 1
  • 4
  • 13
  • 2
    See the answer http://stackoverflow.com/questions/2933/an-executable-python-app/2937#2937 Since Python is usually already installed on OSX and Linux, I'd bet you want to have a look at py2exe. – Alex Marandon Nov 16 '11 at 04:42

2 Answers2

3

I like cx-freeze for simplicity, but PyInstaller is also easy to use. Py2exe may be the traditional solution, but it hasn't been updated in 3 years.

Velociraptors
  • 2,012
  • 16
  • 22
  • 1
    This is a good answer. But also, this is 2011. There's no reason someone shouldn't have python installed already imo. Tell them to install python. – Falmarri Nov 16 '11 at 20:44
  • @Falmarri Yeah the best thing to get people to use your program is to make them hunt down an exe on the net and install it. That's the same reason every game on Windows tells you to hunt down the VC redistributable before it'll work ;) The advantage of cx-freeze is that it supports Python3 while afaik py2exe doesn't. If you have python2.x that's no problem though – Voo Nov 16 '11 at 20:53
  • 1
    @Falmarri There are plenty of non-programmers who can benefit from programs written in python without ever needing to install the interpreter. And installing python requires admin privileges, while stand-alone executables usually don't (depending on what the code actually does). – Velociraptors Nov 16 '11 at 21:11
  • All of those look good, is there a way to package other modules with it, like pygame, for example? – user1048917 Nov 16 '11 at 22:41
  • cx-freeze and pyinstaller both try to detect your code's imports and dependencies automatically. You can force packages to be included (if the detection fails for some reason, but I've never needed to do that). Check the documentation for how to do that. – Velociraptors Nov 16 '11 at 23:02
  • Why is it that when I try to double-click on the application it opens a command line for about a second and then closes? What am I missing? If it helps: I have graphic files in a separate folder called data, I used cx-freeze, and I'm using the normal python modules + pygame. – user1048917 Nov 21 '11 at 01:56
0

One of the traditional solutions is: http://www.py2exe.org/

Raymond Hettinger
  • 216,523
  • 63
  • 388
  • 485