[Tutor] Correct Way to Start a Python Program Under Linux

Alan Gauld alan.gauld at btinternet.com
Fri Jan 19 01:27:45 CET 2007

<pytutor.20.247ob at spamgourmet.com> wrote

> I can run them from a terminal window like
> $ /path/to/file.py
> this works fine and dandy no probs at all but ultimately I want to
> share this program and I want people to launch the program directly
> from a menu and not a shell.

That should be straightforward too.

> now if I create a file launcher on the task bar that points directly 
> to
> the same file it runs and seems to be ok except..

I'm not sure what you mean by a filelauncher.
In my window manager I just add the file path to my menu
by editing a dialog box or config file. which environment are you 

> my program uses subprocess.Popen({command string}, etc)
> and these calls to Popen do not work, only if I run the program from 
> a
> shell window.

How do you know it doesn't work? Do you get an error or just silence?
If you launch a program that writes to stdout then you had better
be sure it has a stdout to write to! Are you sure its not just
dumping its output to /dev/null? OTOH it could also be that the import
path is not set correctly(try checking your PYTHONPATH environment
Can you give us a bit more info about what you mean by the
statement that it doesn't work?

> So am I doing something wrong please tell me?

It sounds like it should be OK, but we need a bit more info
as above...

As a check try writing a very simple program with no external
dependencies and see if it works...

Alan Gauld
Author of the Learn to Program web site

More information about the Tutor mailing list