Problems with 2.0 cgi scripts

Sheila King sheila at spamcop.net
Mon Mar 19 01:41:04 EST 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
qmail. Great.

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:
http://www.thinkspot.net/cgi-bin/pytestscript.py
(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:

subscriberEmail=&command=%3CSelect+an+Item%3E&Submit=Submit+Changes
%response
%stderr
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 2.7.2.3] on linux2
Type "copyright", "credits" or "license" for more information.
Traceback (most recent call last):
  File "listsettings.py", line 5, in ?
    import cgi
ImportError: No module named cgi
# clear __builtin__._
# clear sys.path
# clear sys.argv

...(rest snipped)...

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:
http://www.thinkspot.net/test/listsettings.py

--
Sheila King
http://www.thinkspot.net/sheila/
http://www.k12groups.org/




More information about the Python-list mailing list