RE:WWW-CGI python calls and the environment...

Michael McLay (
Thu, 16 Jun 94 18:29:56 EDT

> it *should* be simple....
> it *is* simple in python-based servers and whatnot, but for
> one reason or another I'm not getting NCSA's httpd to
> call a python script correctly (and yes, I am resetting the
> PYTHONPATH env var just in case, after CGI clobbers it)...

Is the CGI script located in the sys.path that was compiled into your
Python interpreter? The script must be found within the compiled-in
sys.path. Setting PYTHONPATH as an env var in your CGI script will
not work because the CGI script won't be found when "nobody" executes
the script. (The default for NCSA scripts is to have "nobody" execute
CGI scripts and PYTHONPATH will not set by "nobody". This can be
changed in the conf/http.conf file.)

I added /usr/local/etc/httpd/local-bin' to PYTHONPATH in the Setup
file by adding the following lines:


Now my sys.path looks like this:

>>> import sys
>>> print sys.path
['.', '/usr/local/lib/python', '/usr/local/lib/python/test', '/usr/local/lib/python/sun4', '/usr/local/lib/python/stdwin', '/usr/local/etc/httpd/local-bin']

Now adding the following to the httpd conf/srm.conf file will tell
httpd where to look to find the Python scripts.

ScriptAlias /local-bin/ /usr/local/etc/httpd/local-bin/

Now a form entry like the following will work.


Michael J. McLay
National Institute of Standards and Technology
Bld 220 Rm A357 (office), Bld 220 Rm B344 (mail)
Gaithersburg, Maryland 20899, (301)975-4099