FAQ
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

Search Discussions

  • Aahz Maruch at Mar 19, 2001 at 2:57 pm
    In article <fs9bbtg68qne71t853lp89l44uarbb5jk5 at 4ax.com>,
    Sheila King wrote:
    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...
    You can't set the path because you don't own the web server. Simplest
    solution is to set sys.path yourself as the first line of the script.
    --
    --- Aahz <*> (Copyright 2001 by aahz at pobox.com)

    Androgynous poly kinky vanilla queer het Pythonista http://www.rahul.net/aahz/
    Hugs and backrubs -- I break Rule 6

    There's a difference between a person who gets shit zie doesn't deserve
    and a person who gets more shit than zie deserves. --Aahz
  • Sheila King at Mar 20, 2001 at 1:08 am
    On 19 Mar 2001 06:57:37 -0800, aahz at panix.com (Aahz Maruch) wrote in
    comp.lang.python in article <9956p1$8g0$1 at panix3.panix.com>:

    :In article <fs9bbtg68qne71t853lp89l44uarbb5jk5 at 4ax.com>,
    :Sheila King wrote:
    :>
    :>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...
    :
    :You can't set the path because you don't own the web server. Simplest
    :solution is to set sys.path yourself as the first line of the script.

    Thanks, that was one solution.

    However, the other solution was for me to re-install Python with the correct
    exec_prefix option. (I had not done that correctly.)

    Now I've fixed everything, and it's running smoothly. Thanks to D-Man, Michael
    Reilly, and other regulars on the Python Tutor list!

    More details here:
    http://www.aota.net/ubb/Forum3/HTML/001564-1.html

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedMar 19, '01 at 6:41a
activeMar 20, '01 at 1:08a
posts3
users2
websitepython.org

2 users in discussion

Sheila King: 2 posts Aahz Maruch: 1 post

People

Translate

site design / logo © 2022 Grokbase