I use PYTHONPATH to add my own python development directories so that
modules I create myself or don't want to install in the default:
/library/frameworks/python.framework/versions/2.4/lib/python2.4/site- 
packages/

Here is I how set mine up in .bashrc

PYTHONPATH=~/Data/Code/python:~/Data/Adept/Code/python:~/Data/ 
ProSapien/Code/python:~/Sites/ht/lib
export PYTHONPATH

To see what this produces open python

import sys
 >>> sys.path
['', '/Users/smithsm/Data/Code/python',
'/Users/smithsm/Data/Adept/Code/python',
'/Users/smithsm/Data/ProSapien/Code/python',
'/Users/smithsm/Sites/ht/lib',
'/Library/Frameworks/Python.framework/Versions/2.4/lib/python24.zip',  
'/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4', '/ 
Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/plat- 
darwin', '/Library/Frameworks/Python.framework/Versions/2.4/lib/ 
python2.4/plat-mac', '/Library/Frameworks/Python.framework/Versions/ 
2.4/lib/python2.4/plat-mac/lib-scriptpackages', '/Library/Frameworks/ 
Python.framework/Versions/2.4/lib/python2.4/lib-tk', '/Library/ 
Frameworks/Python.framework/Versions/2.4/lib/python2.4/lib-dynload',  
'/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site- 
packages', '/Library/Frameworks/Python.framework/Versions/2.4/lib/ 
python2.4/site-packages/Numeric', '/Library/Frameworks/ 
Python.framework/Versions/2.4/lib/python2.4/site-packages/PIL', '/ 
Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site- 
packages/PyObjC', '/Library/Frameworks/Python.framework/Versions/2.4/ 
lib/python2.4/site-packages/setuptools-0.6a10dev_r42195-py2.4.egg', '/ 
Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site- 
packages/numpy-0.9.5.2006-py2.4-macosx-10.4-ppc.egg', '/Library/ 
Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/ 
numarray-1.5.1-py2.4-macosx-10.4-ppc.egg', '/Library/Frameworks/ 
Python.framework/Versions/2.4/lib/python2.4/site-packages/py2app', '/ 
Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site- 
packages/wx-2.6-mac-ansi']

So the stuff you put in PYTHONPATH get prepended to the list of  
places python looks into for modules when you
do an import.

I don't know how the other stuff (besides what is in PYTHONPATH) gets  
assigned to the sys.path variable. But
apparently different package installers know how to assign stuff to  
sys.path.

For comparison

Here is my PATH
echo $PATH
/usr/local/bin:/opt/local/bin:/usr/local/teTeX/bin/powerpc-apple- 
darwin-current:/bin:/sbin:/usr/bin:/usr/sbin:/Developer/Tools:/ 
Library/Frameworks/Python.framework/Versions/Current/bin/

Then to complicate things even more there are the .pth files that can  
further modify the path
python uses to lookup modules


On 07 Mar, 2006, at 07:56, Ronald Oussoren wrote:

>
> On 7-mrt-2006, at 15:01, Charles Hartman wrote:
>
>>
>> On Mar 7, 2006, at 2:39 AM, Christopher Barker wrote:
>>
>>> Charles Hartman wrote:
>>>> I'm getting really tired of not understanding this: Can someone
>>>> point  me to some single place that explains the whole path /
>>>> PATH /  PYTHONPATH arrangement for Python? I know there are two
>>>> sorts on the  Mac, framework and /usr, and I know some other bits
>>>> and pieces, but I  have no clear overall picture.
>>>> This came to my attention when I downloaded and installed
>>>> IPython,  which looks very nifty. I put it in my MacPython folder
>>>> in / Applications -- but that's not really where it belongs,
>>>
>>> I think ipython is an executable script, so you want to put it
>>> where those go. For stuff not installed by Apple, that is usually:
>>>
>>> /usr/local/bin
>>>
>>> then you want to make sure /usr/local/bin is on your PATH. You do
>>> that by adding it to your /Users/YourName/.profile file, like this:
>>>
>>> export PATH=/usr/local/bin:$PATH
>>>
>>> A little googling should give you more info if you need it.
>>
>> Thank you. This much I knew, but it's useful to have it spelled out.
>>
>> I think that part of what confuses a non-Unix person like me is the
>> distinction PATH / (executable programs and scripts) vs. PYTHONPATH /
>> modules. (This comes up with IPython because embedding its
>> interpreter in another program requires importing a module
>> IPShellEmbed.) I find that my environment contains no PYTHONPATH
>> variable, presumably because I've just been using the modules
>> supplied with Python and with wxPython, and the installers have put
>> them in (some) default places. So I assume that the new installer,
>> too, won't set a PYTHONPATH.
>
> PYTHONPATH is a way to extend the search path for python modules,
> e.g. sys.path,
> while PATH is used by the unix shell to look for programs.
>
> The new installer will indeed not set PYTHONPATH, the default module
> search
> path is good enough. It will update PATH, because the bin directory
> inside
> the framework is not usually on PATH.
>
> Ronald
> _______________________________________________
> Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
> http://mail.python.org/mailman/listinfo/pythonmac-sig

**********************************************************************
Samuel M. Smith Ph.D.
2966 Fort Hill Road
Eagle Mountain, Utah 84043
801-768-2768 voice
801-768-2769 fax
**********************************************************************
"The greatest source of failure and unhappiness in the world is
giving up what we want most for what we want at the moment"
**********************************************************************

_______________________________________________
Pythonmac-SIG maillist  -  Pythonmac-SIG@python.org
http://mail.python.org/mailman/listinfo/pythonmac-sig

Reply via email to