Python

insomniaweek

New Member
Messages
1
Reaction score
0
Points
0
Please help, I've spent nearly an hour trying to get python cgi scripts to work. Can someone please explain how I do this?
I put test.cgi in my cgi-bin folder with
Code:
#!/usr/bin/python



print "Content-Type: text/plain\n\n"



import sys

print sys.version

print sys.modules

in it and saved it. However, when I open it, I get a 500 server error. Please help.

I've tried :
-Changing the code to /user/local/bin/python, /user/local/bin/env python, /user/bin/env python
-Putting it in /scgi-bin
-Changing the main code to a dozen simple varients
-Saving as test.py and making the apache handler cgi-script for .py files
 

lch-x10hosting

New Member
Messages
8
Reaction score
0
Points
0
-Saving as test.py and making the apache handler cgi-script for .py files

I have signed up mainly for this, too. But you're at least further than I am with installing the apache handler, like everybody is referring to. I get: "Your admin has not created a cPAddons configuration yet. Please contact them and ask them to do so."

So, is there some HowTo how one can get Python here?
 

Starshine

Legend Killer
Messages
14,423
Reaction score
0
Points
0
I have signed up mainly for this, too. But you're at least further than I am with installing the apache handler, like everybody is referring to. I get: "Your admin has not created a cPAddons configuration yet. Please contact them and ask them to do so."

So, is there some HowTo how one can get Python here?

Are you trying to click on "Site Software" when you get that error? Site Software is being discontinued by Cpanel and has nothing to do with Python or using Python. If you are looking for software to install, please use Fantastico. ( And if you were aware of the other messages, you would of known the answer to this )
 

lch-x10hosting

New Member
Messages
8
Reaction score
0
Points
0
Are you trying to click on "Site Software" when you get that error?
Yes. I figured that would be where one could setup those things. The only other thing that comes close is the MIME Types module, but that's only to specify mime types, not handlers.
Site Software is being discontinued by Cpanel and has nothing to do with Python or using Python.
Where can I configure things regarding the Apache server like this handler for .py files, then? I'd be grateful if you could point me to some documentation how it is done.
If you are looking for software to install, please use Fantastico. ( And if you were aware of the other messages, you would of known the answer to this )
No, I don't want to install software, I want to be able to use custom Python scripts. (and I read the other messages and all they tell is "configure the apache handler")

Edit:
Okay, nevermind. I got this working myself now. I added the following to my .htaccess to have python scripts working outside of cgi-bin:
Code:
Options +ExecCGI
AddHandler cgi-script .py
Then I tested with the explore.py script from http://moinmo.in/HelpOnInstalling/ApacheOnLinuxFtp and it worked. However, if a script uses a module which is not installed then you get a 500 error and NO INFO at all in your Error log.

Also, I found that FTP is the only reliable method for working on the server. The WebDAV thing is broken for almost all things except viewing directories, chmod and overwriting files. The upload script tends to fail for some things, too.

I saw a post by somebody earlier who had a list of all the modules available to Python here, I'll try to find it again. More official info on this wouldn't hurt, though.
 
Last edited:
Top