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

Paul Berkowitz berkowit@silcom.com
Mon, 14 Apr 2003 08:31:03 -0700


On 4/14/03 8:17 AM, "Kevin Altis" <altis@semi-retired.com> wrote:

> Paul,
> I may not understand what problem you're trying to solve, but it seems like
> you're confusing the PYTHONPATH environment variable which impacts sys.path
> and the PATH environment variable which is what is used to look for programs
> to run independent of Python.
> 
> If you want to be able to run scripts regardless of which directory you're
> in, then the directory that you have the scripts stored needs to be part of
> your PATH environment variable; the scripts also need to be marked
> executable. This is also true for the version of python or pythonw you want
> to run without having to specify a full path.

I have done this. And I have included that directory along with the
traditional directories in a 'setenv PATH ' instruction in
~/Library/init/tcsh/path, which worked earlier. That's supposed to override
the standard tcsh initializatons, but it's not doing it. This is the part
that's not working.
> 
> The PYTHONPATH environment variable is what you use to add directories to
> sys.path for Python. sys.path is specifies the directories and order Python
> searches for modules when you do an import.

This part is working, since I made the environment.plist XML properties list
file as indicated at Russell Owen's website, and put it into an invisible
directory ~/.MacOSX. This works.
> 
> Does this make sense? If so, you can post a follow-up to pythonmac-sig.

Yes. You were right that I was muddling the two. PYTHONPATH is fine, it's my
PATH that isn't.
> 
> Additionally, Bill Bumgarner told me in February that:
>> Anything launched from the Finder [or project builder, whatever], will
>> inherit your environment.plist.
>> 
>> Anything launched at the command line will inherit the command line
>> environment which, unfortunately and by default, overrides
>> environment.plist.
>> 
>> That is broken.   It should be fixed.   I will try to remember to file
>> a bug.

That's what I've hit, I guess. I'm pretty sure that the 'setenv PATH '
instruction in ~/Library/init/tcsh/path was working to get around this bug
earlier, but it isn't now.


-- 
Paul Berkowitz