[Pythonmac-SIG] Newbie environment var problem

Russell E Owen owen@astro.washington.edu
Tue, 8 Oct 2002 09:26:07 -0700


Alan Dyck wrote:

>Right now whenever I want to harness the power of Python I paste in 
>these two lines:
>setenv PATH "${PATH}:/Applications/Python/bin"
>setenv PYTHONPATH "/Users/alandyck/pythonscripts"
>I have read many conflicting hints of how to get these commands into 
>a config or resource file for Terminal (tcsh?). Can someone tell me 
>how to do it?

You want to edit (or if it doesn't exist, then create) a file named 
.cshrc that lives in your home directory. To see if it exists, use 
the "ls -a" command (this includes invisible files that start with a 
period). Here's a portion of my .cshrc, somewhat modified (I normally 
use Pepper, not BBEdit). You will have to modify your paths to suit 
your own needs:

# uncomment the following if using fink:
# source /sw/bin/init.csh
# the following lets me use manually installed versions
# of unix software to override the stuff supplied with Jaguar;
# in particular, I use my own home-built Python
# with readlines and Tkinter support;
# you probably won't want this if you are using fink
# to install unix utilities, but fink isn't yet Jaguar-compatible:
setenv PATH "/usr/local/bin:"$PATH
# point to your source code, wherever you put them
setenv PYTHONPATH "/Users/rowen/PythonRO:"
# if you own BBEdit, this will integrate it into unix:
setenv EDITOR "bbedit -w"
# the following may be useful if you do X-based stuff
# e.g. Tkinter (pre-aqua version) with Python
if( ! $?DISPLAY ) setenv DISPLAY :0.0

One nice way to edit .cshrc is to use BBEdit or BBEdit Lite (free). 
Make sure you specify unix line endings (look through the toolbar at 
the top of the window). You can also use a unix editor such as vi, 
but it's handy to have a reference around (or a friend who knows 
unix).

As of Python 2.2.1 the unix command line python requires unix line 
endings for your source code. I think python 2.3 will be more 
flexible (MacPython 2.2.1 is already flexible but doesn't run from 
the command line). If you need a utility to batch-convert, I'll be 
happy to email you one (contact me privately).

-- Russell