[Pythonmac-SIG] Can't run Python scripts from Terminal

Paul Berkowitz berkowit@silcom.com
Sun, 13 Apr 2003 15:00:50 -0700


On 4/13/03 2:31 PM, "Jack Jansen" <Jack.Jansen@oratrix.com> wrote:

> On zondag, apr 13, 2003, at 22:55 Europe/Amsterdam, Michael Hudson wrote:
> 
>> Paul Berkowitz <berkowit@silcom.com> writes:
>> 
>>> [250-166:~/Library/Scripts/Python] berkowit% lunch.py lunch.py: Command not
>>> found.
>>> 
>> '.' is not in your $PATH; try ./lunch.py instead.
>> 
> I _think_ Michael is right, because you say you use out-of-the-box Python
> 2.2, but just for completeness sake: I had this same thing happening to me
> with Python 2.3 the other day, and I did have . in my path, and it even
> didn't work with a full pathname.
> 
> After much gnashing of teeth and tearing out of hair it turned out that my
> file had Macintosh line separators. Python 2.3 handles any end-of-line
> convention, so "python file.py" works fine, but the unix kernel wants only
> unix end of lines, so the #! line couldn't be interpreted.

Yes, Michael and three people who wrote me privately earlier put me right
about "." I had got too used to omitting it when using 'python'. Thanks to
all of them.

But now I'm back to an earlier issue. I remembered that I had once found a
way to run files from the Terminal by using 'python filename' without
needing to specify the full path, as long as the directory was included in
PYTHONPATH. But I can't do this any more. I have made an 'environment.plist'
file in an invisible ~/.MacOSX/ directory according to Russell Owen's recipe
at <http://www.astro.washington.edu/owen/AquaEnvVar.html>. (I worried about
Mac line endings there myself, but they are indeed Unix line-endings. Both
cat in the Terminal and the Property List Editor see the separate lines.) I
also have a setenv PATH in ~/Library/init/tcsh/path. No joy. I wonder what
I've got wrong this time.


-- 
Paul Berkowitz