[Tutor] Executable

Intatia intatia at paradise.net.nz
Sat Dec 6 04:35:57 EST 2003



Michael Lange wrote:
> On Fri, 05 Dec 2003 17:54:04 -0800
> "Leung Cris" <krazie_mu_boi at hotmail.com> wrote:
> 
> 
>>How do I turn python in to something like an Executable? Right now, I' m only typing in commands...
>>
> 
> 
> If you are running linux or some other unix-like OS, store your code in a file "somefile.py",
> make this file executable with "chmod -v 755 somefile.py" and

I find " chmod +x somefile.py " does the job nicely.
Although I've never gotten into chmod, chown and permissions much so...:)

> run it with "python somefile.py" from a shell.
> If you put something like
> 
> #!/usr/bin/python  (of course this must point to your python executable) or
> #!/usr/bin/env python

Mine is here for some weird reason, perhaps cause I'm running mandrake?:)
#! /usr/local/bin/python

> 
> at the first line of your script you can run it like any other program without the "python" command.
> 
> If you are running windows you just need to double-click somefile.py in the explorer to run it.
> If you store your file with the ".pyw" extension instead of ".py" you can avoid the console
> window pop up when running your file, if you don't like this.
> 
> If you meant to get a standalone executable for windows with no python install needed,
> there is a tool "py2exe"; I don't know much about this, I don't even know where to get it,
> but surely no problem to find it with google.
> However it seems like it can make quite a big executable out of a tiny python script and I've
> heard that it is not so easy to handle. Maybe it is worth to think about if you
> want to distribute your programs.
> 
> I hope this helped
> 
> Best wishes
> 
> Michael
> 
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
> 
> 




More information about the Tutor mailing list