[Pythonmac-SIG] python path, cgi issues, import error
danthorpe at gmail.com
Wed Mar 28 20:21:39 CEST 2007
Hi, I hoping someone can help me with a cgi / import error problem. I
know it's not strictly MacPython related (although I am using Python,
on a Mac), but I've looked all over the web, and most of the answers
to this problem suggest checking your path. Which I've done.
Here are the details....
I'm trying to write a python cgi script which is located at http://
localhost/cgi-bin/python.cgi. In this script I need to import
packages from /Volumes/Data/Users/dt05r/Documents/phd/trunk/code,
specifically geostats.conversion. My directory tree looks something
My http://localhost/cgi-bin/python.cgi (which is in /Library/
WebServer/CGI-Executables) contains this code:
# Required header that tells the browser how to render the text.
print 'Content-type: text/html\n\n'
import cgi, cgitb
import os, os.path, sys
from geostats import *
this prints out the correct $PYTHONPATH, and then spits out an
ImportError: No module named geostats
args = ('No module named geostats',)
I'm setting the $PYTHONPATH using Apache, I have this in my httpd.conf:
SetEnv PYTHONPATH "/Volumes/Data/Users/dt05r/Documents/phd/
Allow from all
I've also made the python code I'm trying to import executable using
chmod -R +x .
If anyone has any idea why I can't import this module - your help is
More information about the Pythonmac-SIG