[Pythonmac-SIG] PYTHONPATH problem

Jack Jansen Jack.Jansen@cwi.nl
Fri, 24 Jan 2003 10:31:49 +0100


On Friday, Jan 24, 2003, at 00:58 Europe/Amsterdam, Dave Hackenyos 
wrote:
> The result of:
>  sh -c 'echo $PYTHONPATH'
> is:
>
> ~/trollcode/Trolls/source
>
> which is also correct.

For some definition of "correct": yes. For Python not, unfortunately:-)

You've done something like
setenv PYTHONPATH "~/trollcode/Trolls/source"
which causes the ~ to be put into the environment string verbatim, in 
stead of being expanded immediately. If you give this string to tcsh 
again it will expand it at that point, and there's no problem. However, 
only a few shells (and a few other programs) do this expansion, most 
programs do not do the expansion of ~ to /Users/davehack. So, you 
should do
setenv PYTHONPATH ~/trollcode/Trolls/source
to have the tilde expanded there-and-then, and everything should be 
fine.

And if you follow Willard Myers' suggestion of setting the variable in 
environment.plist in stead of in your shell startup file (this has some 
advantages: programs that haven't been started via the shell but 
directly from the finder will also see the environment variable): you 
should beware that *no* ~ expansion is done in environment.plist, so 
for PYTHONPATH you should use the full /Users/davehack.
> --
Jack Jansen, <Jack.Jansen@cwi.nl>, http://www.cwi.nl/~jack
If I can't dance I don't want to be part of your revolution -- Emma 
Goldman