PDA

View Full Version : help with Python



HemiVision
01-08-2007, 03:20 PM
Hi,

i just set up a new hosting account and I'm trying to get started with Python. What do I need to do to make a Python file accessible to the web? I tried just dropping it into cgi-bin, but I get a 500 error when I try to load it from a browser. It's just a simple test program to print a line of text.

Thanks for any help,
Rob

blender
01-08-2007, 03:48 PM
Rob,

I believe you'll have to install mod_python to do that. The steps for manually installing it (and Python manually as well) have been posted in the forums here:
http://forums.westhost.com/showthread.php?t=9210&highlight=python

Hope that helps,

Blender

wildjokerdesign
01-09-2007, 10:19 AM
Also did you change the permissions on it? 0755

HemiVision
01-09-2007, 10:29 AM
Rob,

I believe you'll have to install mod_python to do that. The steps for manually installing it (and Python manually as well) have been posted in the forums here:
http://forums.westhost.com/showthread.php?t=9210&highlight=python

Hope that helps,

Blender

Thank you, Blender. I've used mod_python on my local machine so this actually makes a lot more sense to me.

At first I was confused by the instructions because I didn't think I had access to httpd.conf, but I realized I can get at it through SSH.

HemiVision
01-09-2007, 10:30 AM
Also did you change the permissions on it? 0755

yes, i gave it execute permissions

jponiato
01-16-2007, 11:07 AM
Rob,

I believe you'll have to install mod_python to do that. The steps for manually installing it (and Python manually as well) have been posted in the forums here:
http://forums.westhost.com/showthread.php?t=9210&highlight=python

Actually, you don't have to use mod_python to use a python cgi script.
Make sure that a line like this one is the first line in the script:
#!/usr/bin/env python

If that does't work, replace '/usr/bin/env python' with the actual path (including the executable file name) to python, so the line looks like this:
#!/usr/local/bin/python

Oh, and make sure python is installed. From the command line (using ssh), type:
which python

You should see a path to the executable.
Jp

red.mouse
02-07-2007, 01:32 AM
I would like to use mod_pyhon too but I cant get it to install. I've followed the instructions from several other threads but I've had no luck. If I use the default python (installed from the manager app) or 2.4 installed manually I get loads of compiler errors like...

make[1]: Entering directory `/usr/home/mousedelta/mod_python-2.7.11/src'
gcc -I/home/mousedelta/mod_python-2.7.11/src/include -I -I/usr/local/python/include/python2.2 -c -o mod_python.o mod_python.c
In file included from mod_python.c:54:
/home/mousedelta/mod_python-2.7.11/src/include/mod_python.h:63:19: httpd.h: No such file or directory

Does anyone have an idea? It's starting to depress me :)

Rich.

blender
02-07-2007, 08:59 AM
What options are you using in your "configure" to build mod_python?

Additionally, WestHost just released their Python 2.5 site application this week which includes mod_python, so if you don't need v2.4 for a reason then that would be a lot easier than trying to build it yourself.

-Blender

red.mouse
02-07-2007, 04:39 PM
Python 2.5 doesn't seem to been provisioned on my server yet, but I guess I will wait for that.

configuring...

./configure --with-apxs=/usr/local/apache/bin/apxs

I also tried...

./configure --includedir=/usr/local/apache/include --with-apxs=/usr/local/apache/bin/apxs

cheers,
Rich.