Strange Python problem on Linux.

Thomas A. Bryan tbryan at python.net
Tue Feb 29 07:17:52 EST 2000


I'm running Red Hat Linux 6.0, kernel 2.2.5-15, with Python 1.5.2 
(#1, Apr 18 1999, 16:03:16)  [GCC pgcc-2.91.60 19981201 (egcs-1.1.1  
on linux2...

I've never had this problem before in over a year of Python work.
Basically, I have a Python program that I can run by typing
python filename.py
but not by typing 
./filename.py

filename.py is executable, and if I cut its #! line into another 
script, I can run the second script without invoking the 
interpreter explicitly at the command line.  It's only happening with 
this one file; I've never had this problem with other Python programs.
I have no idea what's wrong.  Any hints would be appreciated.  I don't 
trust myself at the moment, so I'm pasting a short session from my 
terminal window here.


$ ls -l ./mdef.py
-rwxrwxr-x   1 tbryan   tbryan      11357 Feb 29 06:51 ./mdef.py
$ ./mdef.py srp1_srp1_19981221_001.mdef > junk.txt
bash: ./mdef.py: No such file or directory
$ mdef.py srp1_srp1_19981221_001.mdef > junk.txt
bash: ./mdef.py: No such file or directory
$ python mdef.py srp1_srp1_19981221_001.mdef > junk.txt
$ head -2 junk.txt 
Meter Header (
        Record Length : 216
$ head -2 mdef.py
#!/usr/bin/python

$ cat > silly.py         
#!/usr/bin/python

print "What's wrong?"
$ chmod u+x silly.py 
$ ./silly.py  
What's wrong?
$ python silly.py 
What's wrong?
$ cp mdef.py copy.py
$ ls -l copy.py
-rwxrwxr-x   1 tbryan   tbryan      11357 Feb 29 07:16 copy.py
$ ./copy.py
bash: ./copy.py: No such file or directory
$ python copy.py srp1_srp1_19981221_001.mdef > junk2.txt
$ head -2 junk2.txt 
Meter Header (
        Record Length : 216
$ /usr/bin/python
Python 1.5.2 (#1, Apr 18 1999, 16:03:16)  [GCC pgcc-2.91.60 19981201 (egcs-1.1.1  on linux2
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> 

too-bewlidered-to-think-of-a-good-timbotish-closing-ly yours
---Tom



More information about the Python-list mailing list