Interpreter problem

G

Greg Lindstrom

I am using python 2.3.5 on a Linux system and have an odd problem
dealing with the 'sha-bang' line. I have a file, driver.py which starts
with

#!/usr/bin/python

and works fine (that is, when I type in ./driver.py at the command
prompt the file runs as expected). I have another file, myotherfile.py
which starts with the exact same line (#!/usr/bin/python) but I get

: bad interpreter: No such file or directory

Hmmmm. That occurs when I have no trailing spaces after the word
'python' on the first line. When I place a single space at the end of
the line I get:

usr/bin/python: can't open file (note the lack of a slash at the
start of the line...is that significant?)

In the 2nd file I placed import sys on line 2, then sys.exit(0) on line
3 to isolate the behavior, so I'm pretty sure the problem deals with
the first line of the file.

If I remove the import sys and sys.exit(0) then type ./myotherfile.py at
the command line it runs as expected. Both files have the same
permission settings (744) and owner (me). I'm been looking at this for
a couple of days and am at a loss. Have any of you seen anything like
this and what can I do about it?

Thanks,
--greg

--
Greg Lindstrom 501 975.4859 (office)
Senior Programmer 501 219-4455 (fax)
NovaSys Health (e-mail address removed)
Little Rock, Arkansas

"We are the music makers, and we are the dreamers of dreams." W.W.

Confidentiality Notice
 
R

Ruud de Jong

Greg Lindstrom schreef:
I am using python 2.3.5 on a Linux system and have an odd problem
dealing with the 'sha-bang' line. I have a file, driver.py which starts
with

#!/usr/bin/python

and works fine (that is, when I type in ./driver.py at the command
prompt the file runs as expected). I have another file, myotherfile.py
which starts with the exact same line (#!/usr/bin/python) but I get

: bad interpreter: No such file or directory
I remember encountering a similar problem once. It turned out that
the python interpreter, when invoked through the #! line, will only work
properly if the line ends in a Unix newline (only a LF: '\n'). When you
create the line on a Windows or Mac platform the line ending will
typically be different: CR/LF (\r\n) for Windows, CR (\r) for Mac. For
the body of the python script this doesn't matter, but it does matter
for the #! line.
Not sure if this applies here, but who knows.

Good luck, Ruud
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,128
Latest member
ElwoodPhil
Top