[Pythonmac-SIG] Setting PYTHONPATH on mac os x

Bob Ippolito bob at redivi.com
Fri Apr 30 13:23:49 EDT 2004


On Apr 30, 2004, at 1:04 PM, Jim Harrison wrote:

> on 4/30/04 11:25 AM, John P Speno at speno at isc.upenn.edu wrote:
>
>> On Thu, Apr 29, 2004 at 08:49:40PM -0400, Jason Van Anden wrote:
>>> Major newbie question - but one that was not so easy to parse out of 
>>> a
>>> Google search for "set pythonpath mac" - until now, hopefully, with
>>> your help.  How do I add to the pythonpath on mac os x?
>>
>> I just added this to the Pythonmac FAQ here:
>>
>> http://pythonmac.org/wiki/FAQ
>>
>> Look in the general section.
>>
>> Please let me know if that answers your question.
>
> Note that the Apple tech note referenced in the wiki entry ignores 
> ignores a
> number of details that would be useful for newbies: the correct format 
> for
> multiple paths associated with one variable name, how to get the 
> Property
> List Editor or other editing environment to find/open the .MacOSX 
> directory,
> and so on. There are also several utilities that can be helpful, such 
> as the
> RCEnvironment prefpane for viewing and setting environment variables, 
> BBEdit
> for opening and editing hidden directories/files and OnyX for revealing
> hidden directories/files so that any editor can be used.
>
> I added comments about these to the wiki entry. It would probably be a 
> good
> idea of someone knowledgeable checked my edit to make sure it's 
> entirely
> correct.

I would suggest that people use pth files instead of trying to use 
PYTHONPATH.  Given a user account with privileges to write to a site 
directory, I think that PYTHONPATH is *ONLY* appropriate for something 
like a bootstrap shell script that starts a particular application.  
There isn't a FAQ entry for using pth files yet, but you can search the 
archives here, they've been talked about a number of times.

In short, to add a directory by way of a pth file, simply make a plain 
text file with any name that has "pth" as the extension.  The contents 
of the file should be the absolute path you would like to add (~ and 
$vars are not allowed).  Move the file to a site directory (such as 
/Library/Python/2.3 for OS X 10.3).

This has the distinct advantage that it works regardless of what your 
environment happens to be, and it only affects python interpreters that 
use that site directory.  Unconditionally setting  PYTHONPATH will 
affect EVERY python, regardless of Python version or vendor (apple, 
fink, darwinports, user compiled, etc.).

-bob




More information about the Pythonmac-SIG mailing list