Problems with 2.0 cgi scripts
sheila at spamcop.net
Mon Mar 19 07:41:04 CET 2001
My webhost has Python 1.5.1 installed as a core tool. However, I never could
get the smtplib module commands to work properly.
So, I installed Python-2.0 in my own web space. It has been fine for command
line tasks and I have also used it as a script for filtering e-mail invoked by
However, now I try to run some cgi scripts with it. Well, I do have a
functioning cgi script on my site with Python-2.0:
(It's just "Hello, World")
So, I know I can run Python-2.0 cgi scripts.
Now comes the problem:
If I try to run a Python-2.0 script that needs to import a module, I get
internal server errors, and the log file reports something like this:
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
'import site' failed; traceback:
ImportError: No module named site
Python 2.0 (#1, Jan 15 2001, 01:09:04)
[GCC 22.214.171.124] on linux2
Type "copyright", "credits" or "license" for more information.
Traceback (most recent call last):
File "listsettings.py", line 5, in ?
ImportError: No module named cgi
# clear __builtin__._
# clear sys.path
# clear sys.argv
Yet, the same script will run from the command line during a telnet session
and find all the files.
So, basically, it cannot find the modules when I run it as a cgi-script. I
have all the paths set correctly, and the permissions set correctly. Grr, I'm
frustrated with this one by now...
Does anyone have any idea what could be causing behavior of this type?
(It isn't the script, because the script runs fine on my home machine under
Apache, and it runs fine from my web host at the command line. Unfortunately,
since this is a custom install, it is classified as a 3rd party script as far
as support goes: I'm on my own. :-(
If you want to look at the script itself, it is here:
More information about the Python-list