Python scripts wont run - HELP

Nick Vargish nav+posts at bandersnatch.org
Mon Jul 18 15:47:03 EDT 2005


windozbloz <nethawg1 at verizon.net> writes:

> It now works from the command line like you said.  Shouldn't I also be able
> to 'click' an icon that has been set to executable and launch the whole
> process that way?

You'll need to put an interpreter line at the beginning of your
script, as other posters have indicated. This tells the shell how to
handle the file.

When you double-click a program icon in your file browser, the browser
starts a shell process which is handed the file's name for
execution.

#!/usr/bin/python

Says, "This file is  interpreted by /usr/bin/python". The idiom you
will often see:

#!/usr/bin/env python

Says, "Find 'python' in this user's environment, and give this file to
that program for interpretation". That allows you to use a different
python interpreter (say, /usr/local/bin/python if that comes first on
your PATH environment variable), and allows the script to be more
friendly for systems that do not have a /usr/bin/python.

Depending on the GUI, you may not see a terminal window open for the
script's execution, or the terminal might close as soon as the script
exits, which will prevent you from looking at any output. Unless the
program has a GUI, running it from the command-line is usually better
than double-clicking it in a file browser.

Nick

-- 
#include<stdio.h>    /* sigmask (sig.c) 20041028 PUBLIC DOMAIN */
int main(c,v)char *v;{return !c?putchar(*   /* cc -o sig sig.c */
v-1)&&main(0,v+1):main(0,"Ojdl!Wbshjti!=ojdlAwbshjti/psh?\v\1");}



More information about the Python-list mailing list