PYTHONPATH on OS X

Graham Dumpleton Graham.Dumpleton at gmail.com
Wed Oct 10 18:59:58 EDT 2007


On Oct 11, 8:00 am, "mhearne808[insert-at-sign-here]gmail[insert-dot-
here]com" <mhearne... at gmail.com> wrote:
> I'm missing something major here.  I'm trying to add a directory to my
> python path using the PYTHONPATH environment variable, and it's being
> ignored by the Python interactive shell.
>
> Below is a capture of what I did.  Note that my newfolder appears
> nowhere on the list of directories in sys.path.  How do I get Python
> to pay attention to my shell variables?
>
> Using bash on OS X 10.4.10.
>
> %:~ user$ echo $PYTHONPATH
>
> %:~ user$ PYTHONPATH=/Users/user/newfolder
> %:~ user$ echo $PYTHONPATH
> /Users/user/newfolder
> %:~ user$ python
> Python 2.5.1 (r251:54863, Aug 10 2007, 10:46:58)
> [GCC 4.0.1 (Apple Computer, Inc. build 5363)] on darwin
> Type "help", "copyright", "credits" or "license" for more information.>>> import sys
> >>> sys.path
>
> ['', '/usr/local/lib/python2.5/site-packages/
> setuptools-0.7a1dev_r56320-py2.5.egg', '/usr/local/lib/python2.5/site-
> packages/ipython1-0.9alpha2-py2.5.egg', '/usr/local/lib/python2.5/site-
> packages/SQLAlchemy-0.4.0beta5-py2.5.egg', '/usr/local/lib/python2.5/
> site-packages/MySQL_python-1.2.2-py2.5-macosx-10.3-i386.egg', '/usr/
> local/lib/python25.zip', '/usr/local/lib/python2.5', '/usr/local/lib/
> python2.5/plat-darwin', '/usr/local/lib/python2.5/plat-mac', '/usr/
> local/lib/python2.5/plat-mac/lib-scriptpackages', '/usr/local/lib/
> python2.5/lib-tk', '/usr/local/lib/python2.5/lib-dynload', '/usr/local/
> lib/python2.5/site-packages', '/usr/local/lib/python2.5/site-packages/
> PIL']

You need to export the environment variable.

  export PYTHONPATH

Graham




More information about the Python-list mailing list