[Tutor] Setting PYTHONPATH in FreeBSD/Linux
Magnus Lyckå
magnus@thinkware.se
Wed Jul 9 07:36:02 2003
This has nothing to do with Python, but since it's such
a sunny day here... ;)
At 23:46 2003-07-08 -0700, Tony Cappellini wrote:
>set pythonpath = /home/myhomedir
>to my .cshrc file.
>(all of the environment variables in the .cshrc file are lowercase, so I
>also made pythonpath lowercase)
I'm not at all sure that pythonpath is the same thing
as PYTHONPATH.
By the way, I actually think you will be happier
in the long run using bash. Most documentation on
how to set things up assume a Bourne shell compatible
shell, and csh and tcsh aren't. bash is, while still
offering all the bells and whistles of tcsh.
>I've logged out and back in and verified that my new environment variable
>is set, by typing
>set.
But that's not enough! Variables defined with just "set" are
not inherited by spawned processes. .cshrc is sourced every
time you start up a csh process. Python is obviously not csh.
.cshrc is only intended for stuff you want to be defined in
your csh processes, and not anywhere else. At least that's how
I understand it. I don't run csh very often since I saw the
light ;) in 1996 or so.
In csh I think you need to do
setenv PYTHONPATH /home/myhomedir
and I think you should put that in .login, which is just sourced
in the login shell. PYTHONPATH will then be inherited by all sub
processes, so there is no need to run it over and over again as
you would if it was placed in .cshrc.
in bash you would do
export PYTHONPATH=/home/myhomedir
or
PYTHONPATH=/home/myhomedir
export PYTHONPATH
if you want to stay compatible with older shells.
Another option is to add the path in your Python program:
import sys
sys.path.append('/home/myhomedir')
--
Magnus Lycka (It's really Lyckå), magnus@thinkware.se
Thinkware AB, Sweden, www.thinkware.se
I code Python ~ The Agile Programming Language