[Tutor] Shebang problem

Matthew Richardson marichar@csusb.edu
Tue Jul 1 13:16:03 2003


On Tue, 2003-07-01 at 10:18, Rick Thomas wrote:
> On Friday 27 June 2003 17:34, Abel Daniel wrote:
> > Rick Thomas wrote:
> > > Hi,
> > >
> > > I'm very new to programming and am plodding my way through Alan Gauld's
> > > book 'Learn to Program Using Python'.  At present I can't get my programs
> > > to execute using the Shebang trick.
> > >
> > > #!/usr/bin/python
> > >
> > > My scripts ran fine when I was using SuSE 7.3 but I've recently upgraded
> > > to 8.3 and wondered if this is somehow the problem.  My scripts run ok 
> > > if I type for example 'python foo.py' in a terminal.
> > >
> > > Any advice would be much appreciated.
>  
> Abel Daniel advised
> 
> > Pasting the exact error message would have helped to narrow the problem,
> > but here are some ideas:
> >
> > - try 'which python' to find out which program runs when you do
> > 'python foo.py'. That way you can be sure that you are trying to use the
> > same interpreter in both cases.
> >
> > - you could try using a '#!/usr/bin/env python' shebang line, which will
> > more-or-less ensure that you get the same interpreter. (I guess this
> > won't help if the idea above didn't.)
> >
> > - check that you have executable permissions on the file.
> >
> > Abel Daniel
> 
> The exact error message I get is 'bash: foo.py: command not found'.  When I 
> type in 'which python' at a terminal I get  /usr/bin/python which is the 
> correct path for my scripts.  I've tried changing the shebang line to 
> #!/usr/bin/env python but I got the same error message as above.  I know all 
> my scripts are executable as I've always used the 'chmod' u+x command after 
> creating a script file.
> 
> further advice would be much appriciated.
> 
> Rick Thomas.
> 
Have you tried executing the script with the full path name or changing
to the directory it is in and executing it with ./foo.py?

--Matt
-- 
Matt Richardson
Instructional Support Technician
Department of Art
CSU San Bernardino