directly executing a python script in Unix

Mike Mellor mike.mellor at us.army.mil
Mon Feb 4 16:38:02 EST 2002


On Mon, 04 Feb 2002 20:24:37 +0000
python-list at yahoogroups.com wrote:

>    Date: 4 Feb 2002 12:08:43 -0800
>    From: laymon at crd.ge.com (Marc Laymon)
> Subject: directly executing a python script in Unix
> 
> I am just learning python.  I have written a few simple scripts which
> run fine when invoked using "python myscript.py".  The Python manual
> says you can execute a Python script directly In Unix by making the
> first line "#!/usr/bin/python", then giving the command
> "./myscript.py".  However, when I try this, I get an error "Command
> not found.".  I get the same error under both Linux and Solaris. 
> Using the same format for perl works fine.  Why doesn't the
> "#!/usr/bin/python" line work for Python ?  (perl and python are both
> in /usr/bin on my Linux system.)
> 
> Thanks.
> 
> Marc Laymon
> -- 

Marc - 

You need to make the script executable:

chmod +x myscript.py

That should do it.  Hope it helps.

Mike




More information about the Python-list mailing list