[Pythonmac-SIG] Running Python scripts without full paths
kevin parks
kevin@macosx.com
Sun, 1 Dec 2002 03:33:44 +0900
For what it is worth i have never ever ever found a solution to this=20
problem My path is set in the
~/Library/init/tcsh/environment.mine
by adding:
setenv PATH "~/bin:/Users/kevin:${PATH}"
since path is an environmental variable i am not sure why there is a=20
path file (and why it is not called path.mine) and a separate=20
environment.mine file.
Should i have set this in:
~/Library/init/tcsh/path ??? and if so how? it is a mystery and=20
Apple is not going to tell you either.
I also have the sbang set all fine and the file set to executable and=20
no go. I have asked this on the list over and over and many fine folks=20=
have tried to help me but to no avail. If i execute the script with the=20=
full path it is fine if i just move to the directory (which *IS* in my=20=
path), make a script and then try to execute it i get "command not=20
found". I checked my sanity and did the same thing on a linux box and=20
everything works, so i have no clue. The weirdest thing of all is if=20
you hop into the terminal and print your path from the command line it=20=
show that the dir is listed in the path after all.
Intensely frustrating. I have no idea why this is.
I have just bit the bullet and type the whole freaking path for now. I=20=
hate this part of Mach-o python and really dislike how Apple keeps=20
changing the unixy things with the terminal and not giving anything but=20=
the most terse instructions on how to customize tcsh. It changed from=20
10.1 to 10.2. The system they have is very nice and BSD-y but it takes=20=
days of investigation to get your stupid ~/Library/init/tcsh/ files=20
working. Once you figure out what the are and what they do. I suspect=20
that most folks have ignored the BSD way and just put a .tcshrc file in=20=
their home directory which overrides.
If i am right what the OS X ~/Library/init/tcsh/ system tries to do is=20=
have a system wide set-up with the shell which you then amend with your=20=
own ~/Library/init/tcsh files, but if you just put a .tcshrc file in=20
your home the system wide startup log-in log-out aliases and path files=20=
get clobbered, no? Who knows? Someone at Apple ought to make this clear=20=
instead of just that dumb single cryptic file that the give you in
/usr/share/tcsh/examples/README
You know the files they moved from /usr/share/init/tcsh without telling=20=
anyone making sure that anyone who used the terminal had a few days of=20=
frustration after moving to Jaguar.
Frankly i still can't figure out for sure what is going on with tcsh on=20=
OS X. On the NeXT is was simple you had your
.tcshrc .login and .logout files in your home and that was it. Plus=20
they were documented. I am still not sure what is supposed to go in the
aliases.mine - shell aliases
completions.mine - completions
environment.mine - environment
rc.mine - run commands
path - command search path
files exactly. I realize that this is just .tcshrc broken up into=20
separate files, but what is rc.mine (is that supposed to be a=20
substitute for the .cshrc file?) and why is path not path.mine? and as=20=
i stated above since path is an environmental variable i am not sure=20
why there is a path file and a separate environment.mine file. The=20
whole thing is a mess and not at all documented. REAL examples would=20
have been nice. I am not sure who Fred Massachusetts Institute of=20
Technology tritan@mit.edu is but i sure wish he would have written a=20
less terse readme.
I realize that i am a freak in that 1) i want actually write scripts to=20=
execute from the shell (heaven forbid!)
2) i like the terminal and actually want to use it.
But Apple hates users like me apparently since the do all they can to=20
make sure you don't use the shell, including moving stuff around and=20
not giving you any documentation on how to set up your shell. The csh=20
books out there are not any use either since they have nothing on the=20
new BSD ways. I hate this! I would love to know once and for all how to=20=
set up my shell so that i can add directories to my path like ~/bin
and type
% foo.py
and get a result. But i guess that is just never going to happen.
> Thanks, Neil. That's the odd thing. I did all that (sorry I forgot to=20=
> mention it), except I left a space between after the #! , before=20
> 'usr/bin/env python'. I've now tried it all ways:
>
> =A0=A0=A0=A0#!/usr/bin/python
> =A0=A0=A0=A0#!/ usr/bin/python
> =A0=A0=A0=A0#!/usr/bin/env python
> =A0=A0=A0=A0#!/ usr/bin/env python
>
> Even when I give the full path to the file:
>
> [250-166:~] berkowit% ~/Library/Scripts/Python/module1.py
> /Users/berkowit/Library/Scripts/Python/module1.py: Command not found.
>
>
>
> I get "Command not found."every time. =A0What am I doing wrong?
>
> Here are the permissions:
>
> -rwxr-xr-x =A01 berkowit =A0wheel =A0=A0=A048 Nov 30 08:47 module1.py
>
> Here's the current version of the file (with Unix newlines):
>
> #!usr/bin/python
> print 'Hello module world!