[Pythonmac-SIG] [Q]PYTHONPATH

Lee Phillips lists@lee-phillips.org
Sat, 3 May 2003 19:59:02 -0400


On Thu, May 01, 2003 at 09:11:10PM -0300, Lizardo H. C.M. Nunes wrote:
> [....]
> So, I want to install some modules; I've just installed dislin ( 
> http://www.linmpi.mpg.de/dislin/ ) . Examples compiled fine and now I 
> want to set the PYTHONPATH. I am not a unix expert and I couldn't do 
> it. (Everything I've tried failed.)

That's what's called an environment variable - once set, it is 
inhereted by all the child processes. So, if you really need
for it to be set, you want to have it set automatically each time
you start a shell (each time you open a Terminal window). To see
its value, type "echo $PYTHONPATH". To set it, for the sh or bash
shells (what I use) type PYTHONPATH=/path/that/you/want. If you
are using the csh or tcsh (might still be the default for OSX) you
should change to bash! Or, more seriously, the command is 
"set PYTHONPATH = /path/that/you/want". 

To get it set automatically, put the commands in the special
files that get executed when you start a shell. For bash, that's
.bashrc, and for tcsh or csh that's .cshrc (I think - check:
"ls -ld .*" will show you the "dotfiles" that you have). These
are in your home directory (~ or /Users/yourname).

But what I do is, rather than put the modules that I want to be
able to import all over the place and fiddle with PYTHONPATH, is
just put them in /usr/lib/python2.2/. If it's a package instead
of just a single module, you put it in /usr/lib/python2.2/site-packages/.
That's where you would put Numeric, for example. If you put them
there you will be able to import them automatically. You can do
this because you can assume root priviledges (sudo). Also,
it's fun to look around in there and examine the modules that come
with the installation.
 
> P.S. 2: How can I add readline support, compile it all again?

I added this, if I recall correctly, by downloading something
from Bill Bumgardner's website. I did not have to recompile.
You will have, however, to have at least the July 2002 developer
tools update (I think that's the right date). So look there, or
in the archives to this list.