CGI Python problem

Tim Chase python.list at tim.thechases.com
Thu Nov 6 20:03:51 EST 2008


> As for writing some perl, not too sure how to do that, but from the
> information in phpinfo I logged onto the webserver machine and did a
> "whereis python" - it came back blank! Of course doing a whereis perl
> gave a non-blank answer. So this seems to be the route cause of my
> trouble.

Indeed!  I made the rash assumption that it executed from the 
command line (or as a lynxcgi from within Lynx).  Not having 
Python will make it awfully hard to run python apps.

While it's possible that Python is installed, but simply not 
found by "whereis" (I don't know this tool), you could try

   which python

if it's in your path, or the more brute-force search:

   find /usr -name python

(ignore any permission-related responses) to see if it's 
installed somewhere that's not on your path.  If not, you may 
have to either request that your admins install Python, or (if 
you've at least got a compiler on the machine) build your own 
deployment of Python in your user directory.  Others on the list 
may be able to direct you to good resources on building Python in 
non-standard locations (I'm admin on all the boxes I use, or the 
admins already have python2.4 or later installed).

> Now to work around that, I've tried to change the shebang in the
> python test file to the location of python on my local machine, but
> still no use?

If your CGI is on machine A, and your local machine is machine B, 
changing the shebang won't help, as you've noticed.

You might try creating a shell-script CGI to give you the info 
you need:

   #!/bin/sh
   # saved as ~/public_html/cgi-bin/foo.cgi
   echo Content-type:text/plain
   echo
   echo Python is found at:
   which python
   # find /usr -name python
   echo Use the above as your shebang path.

and then

   chmod ugo+x ~/public_html/cgi-bin/foo.cgi

You should then be able to browse to

   http://yourserver.example.com/~totoole/cgi-bin/foo.cgi

to see if/where the python executable is stored for use in your 
shebang line.

Yet another round in the game of troubleshooting...

-tkc









More information about the Python-list mailing list