Re: Changing Pythonpath

Steven D. Majewski (sdm7g@elvis.med.virginia.edu)
Wed, 23 Mar 1994 09:18:44 -0500

On Mar 22, 21:54, Craig Meyer wrote:
>
> 'Tis but a newbie dork-question, but I can't move further through the
> tutorial if I can't change my pythonpath AFTER having installed Python
> 1.0.1 on "my" HP series-700 (cookbook installation: "./configure" and
> then "make"). It is installed in my personal directory
> "~/python/python-1.0.1/"
>

On unix ( and I think DOS ) you can set PYTHONPATH from the shell
before running Python. The PYTHONPATH variable gets prepended to
the compiled in settings.

Within Python, those values are accessable ( and changable ) via the
list sys.path.

$ PYTHONPATH=$HOME/Python:$HOME/Python/Lib
$ python
Python 1.0.1 (Mar 15 1994)
Copyright 1991-1994 Stichting Mathematisch Centrum, Amsterdam
>>> import sys
>>> sys.path
['/home/sdm7g/Python', '/home/sdm7g/Python/Lib', '.',
'/usr/local/lib/python', '/usr/local/lib/python/test']
>>> sys.path.append( '/home/sdm7g/Python/Test' )
>>> sys.path
['/home/sdm7g/Python', '/home/sdm7g/Python/Lib', '.',
'/usr/local/lib/python', '/usr/local/lib/python/test', '/home/sdm7g/Python/Test']
>>>

- Steve M.