PYTHONPATH on OS X
Diez B. Roggisch
deets at nospam.web.de
Wed Oct 10 18:22:55 EDT 2007
mhearne808[insert-at-sign-here]gmail[insert-dot-here]com schrieb:
> 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']
Use
export PYTHONPATH=....
to pass environment vars to subprocesses.
Basic unix shell knowledge :)
$ man bash
...
export -p
The supplied names are marked for automatic export to
the envi-
ronment of subsequently executed commands. If the -f
option is
given, the names refer to functions. If no names are
given, or
if the -p option is supplied, a list of all names
that are
exported in this shell is printed. The -n option
causes the
export property to be removed from the named variables.
export
returns an exit status of 0 unless an invalid option is
encoun-
tered, one of the names is not a valid shell variable
name, or
-f is supplied with a name that is not a function.
...
Diez
More information about the Python-list
mailing list