CGI script refuses to run python

Harry George hgg9140 at fred.local
Sat Apr 7 22:35:55 EDT 2001


Do you happen to have another python installation in /usr/local/bin?
You might try:

#!/usr/local/bin/python2.0

Another possibility is that the web server is running at very low
permissions, and cannot read or execute one of the dirs in the path to
your /usr/local/lib/python2.0.  E.g., if these are set for r-x for a
group you personally belong to, you will be able to run them on the
commandline.  But if they are not r-x for all, then "nobody" will not
be able to see them.

"vikas" <viznogoud at yahoo.com> writes:

> The binary is in /usr/local/bin.
> The libraries are in /usr/local/lib/python2.0.
> 
> Python 2.0 (#1, Feb 26 2001, 14:23:43)
> [GCC 2.95.2 19991024 (release)] on freebsd4
> Type "copyright", "credits" or "license" for more information.
> >>>
> >>>
> >>> import sys
> >>> sys.path
> ['', '/usr/local/lib/python2.0', '/usr/local/lib/python2.0/plat-freebsd4',
> '/usr/local/lib/python2.0/lib-tk', '/usr/local/lib/python2.0/lib-dynload',
> '/usr/local/lib/python2.0/site-packages']
> >>>
> 
> The scripts run fine when run from a shell. They just don't when run from
> CGI.
> 
> Like I mentioned, I ran a CGI script like yours but even smaller.
> It does not even get past the header (#!/usr/local/bin/python).
> 
> Basically when python is invoked it appears to load up a set of default
> modules.
> (site, posix, posixpath, stat, UserDict)
> 
> It complains about not finding those modules.
> Actually I was wrong in my prev post. It was never able to find any modules.
> The server error log still shows the same error, but the browser shows no
> error as long as the CGI script does not itself import any modules, only
> prints.
> 
> Vikas
> 
> Sheila King <sheila at spamcop.net> wrote in message
> news:a4upctc9bfo3drir737ptcl0b46vpjrsuo at 4ax.com...
> > On Thu, 5 Apr 2001 15:46:25 -0700, "vikas" <viznogoud at yahoo.com> wrote in
> > comp.lang.python in article <tcpt6vsugf6b62 at corp.supernews.com>:
> >
> > :Ok, I have the same error.
> > :However, my sys.path has the correct paths in it.
> > :i.e. python is installed in /usr/local/lib/python2.0.
> > :
> > :I tried making shell scripts to set the env
> > :and then try to invoke python. It seems like if
> > :I set the PYTHONPATH before invoking python,
> > :it works. But any python scripts invoked by that
> > :python scripts don't work!
> > :
> > :Any ideas?
> > :
> >
> > It really doesn't sound to me, like you have it installed in the right
> place.
> > If you did, surely it would be able to find everything it needs for the
> > scripts to run??? Is the binary in /usr/local/lib also? Usually it should
> be
> > in /usr/local/bin I believe.
> >
> > Run a script similar to this one (This one is a cgi-script, meant to be
> > invoked from a browser, but it should run at the command line, too):
> >
> > ------------------------------------------
> > #! /usr/local/bin/python2.0
> >
> > import sys
> > print "Content-type: text/plain\n\n"
> >
> > print sys.version
> > print
> >
> > for path in sys.path:
> > print path
> >
> > print
> > print "Those are the paths"
> > ------------------------------------------
> >
> > That will show what the path actually are. If you do not have the binary
> > installed where it expects, and the libraries installed where it expects,
> I'd
> > think you'd be having problems.
> >
> > The work-around that I had, before I re-installed, was to reset the paths
> > inside of each script right at the beginning of the script, to point to
> the
> > directories where the binary and the libraries were installed.
> >
> > --
> > Sheila King
> > http://www.thinkspot.net/sheila/
> > http://www.k12groups.org/
> >
> >
> > :Sheila King <sheila at spamcop.net> wrote in message
> > :news:hhanctghter75fs890kk98ttmue18pi2p2 at 4ax.com...
> > :> Try this URL:
> > :>
> > :> http://www.aota.net/ubb/Forum3/HTML/001564-1.html
> > :>
> > :> --
> > :> Sheila King
> > :> http://www.thinkspot.net/sheila/
> > :> http://www.k12groups.org/
> > :>
> > :>
> > :> On Wed, 4 Apr 2001 14:53:46 -0700, "vikas" <viznogoud at yahoo.com> wrote
> in
> > :> comp.lang.python in article <tcn5o76ljn8sc3 at corp.supernews.com>:
> > :>
> > :> :Hi,
> > :> :I am trying to get this python cgi script to work on apache.
> > :> :I made a test script to break down the problem.
> > :> :
> > :> :So now the script is just:
> > :> :#!/usr/local/bin/python
> > :> :
> > :> :I still get the same error in the web server log:
> > :> :
> > :> :Could not find platform independant libraries <prefix>
> > :> :Could not find platform dependant libraries <exec_prefix>
> > :> :Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
> > :> :'import site' failed; use -v for traceback
> > :> :
> > :> :How do I fix this?
> > :> :
> > :> :Thanx
> > :> :Vikas
> > :> :
> > :>
> > :
> >



More information about the Python-list mailing list