471,357 Members | 1,046 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,357 software developers and data experts.

PYTHONPATH on OS X

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']

Oct 10 '07 #1
4 6838
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
Oct 10 '07 #2
On Oct 10, 11:00 pm, "mhearne808[insert-at-sign-here]gmail[insert-dot-
here]com" <mhearne...@gmail.comwrote:
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']
Try
export PYTHONPATH=/Users/user/newfolder

Otherwise (without 'export') the variable is defined in the shell but
not passed on when you launch python.

Cheers,
Anthony

Oct 10 '07 #3
On Oct 11, 8:00 am, "mhearne808[insert-at-sign-here]gmail[insert-dot-
here]com" <mhearne...@gmail.comwrote:
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

Oct 10 '07 #4
On Oct 10, 4:59 pm, Graham Dumpleton <Graham.Dumple...@gmail.com>
wrote:
On Oct 11, 8:00 am, "mhearne808[insert-at-sign-here]gmail[insert-dot-

here]com" <mhearne...@gmail.comwrote:
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
Thanks all - I'm recently back to using Unix (Mac) after 5 years of
being on a PC. I guess I thought export was just another way of doing
assignment. My bad.

--Mike

Oct 11 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Rami A. Kishek | last post: by
2 posts views Thread by Eric Wichterich | last post: by
4 posts views Thread by r.e.s. | last post: by
8 posts views Thread by Tero Pihlajakoski | last post: by
3 posts views Thread by D Denholm | last post: by
10 posts views Thread by sushant.sirsikar | last post: by
reply views Thread by Michael Yanowitz | last post: by
1 post views Thread by Aljosa Mohorovic | last post: by
reply views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.