[Tutor] Shebang problem

Abel Daniel abli@freemail.hu
Fri Jun 27 12:35:52 2003


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.
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