error

Problems with the Windows version of XAMPP, questions, comments, and anything related.

error

Postby shyam » 29. April 2017 08:39

#!/Python27/pythonold/python.exe
import mysql.connnector
import cgi,cgitb
print("content-type:text/html\n")
db=mysql.connector.connect(host="localhost",user="root",password="xyz",database="shyam")
cursor=db.cursor()
cursor.execute("select version()")
data=cursor.fetchone()
print("database version %s" % data)
print("<a href="#">home</a>")
db.close()
-------------------------------------------------------
this is my code when i run this with filename.py i am getting the error as:-
Server error!

The server encountered an internal error and was unable to complete your request.

Error message:
couldn't create child process: 720002: exam2.py

If you think this is a server error, please contact the webmaster.

Error 500

localhost
Apache/2.4.23 (Win32) OpenSSL/1.0.2h PHP/7.0.9
shyam
 
Posts: 1
Joined: 29. April 2017 08:34
XAMPP version: 3.2.2
Operating System: windows

Re: error

Postby Nobbie » 29. April 2017 23:53

Python is not part of Xampp, i dont think you will get Python support in the Xampp Forum.
Nobbie
 
Posts: 13179
Joined: 09. March 2008 13:04

Re: error

Postby gsmith » 30. April 2017 06:02

While I understand the reasoning for Nobbie's answer above, I see this as more of supporting Apache rather than Python so I'm game.

In xampp\apache\conf\httpd.conf find the line similar to this

AddHandler cgi-script .cgi .pl .asp

add .py to the end of it, save and restart Apache.

If there is an error in your code (I don't read python) it will still bounce, but if the code is correct, it will work.
gsmith
 
Posts: 278
Joined: 29. November 2013 18:04
Location: San Diego
XAMPP version: 0.0.0
Operating System: Win 10/2012R VS 14,15,16

Re: error

Postby Nobbie » 30. April 2017 12:39

gsmith wrote:AddHandler cgi-script .cgi .pl .asp

add .py to the end of it, save and restart Apache.


I am pretty sure that this does not solve the issue, a missing CGI handler for .py would simply result in MIME Type "text", what means that Apache would deliver the module as simple text, i.e. the server would show the python code instead of executing it. I gave it a try on my Linux Xampp and it behaves exactly as expected.

Anyway, there *should* be an error message in error_log, which can give a clue what is going wrong. And it would be helpfull to know, where this script is stored (full pathname) and how it is called in the browser (full URL). Due to an ScriptAlias Clause for cgi-bin, we might solve it in the Xampp universum. If it is a Python problem, we cannot solve it here.

P.S.: An extremely strange message is "couldn't create child process: 720002: exam2.py", as you told us that you called that script "filename.py". Where is "exam2.py" coming from????
Nobbie
 
Posts: 13179
Joined: 09. March 2008 13:04

Re: error

Postby gsmith » 01. May 2017 00:47

True, just prints out the script's code as plain text.
Not a ScriptAlias'd directory or doesn't have ExecCGI turn on for said directory 403s.

Couldn't create child process is what you get when the shebang is incorrect.
gsmith
 
Posts: 278
Joined: 29. November 2013 18:04
Location: San Diego
XAMPP version: 0.0.0
Operating System: Win 10/2012R VS 14,15,16

Re: error

Postby Nobbie » 01. May 2017 09:37

gsmith wrote:Couldn't create child process is what you get when the shebang is incorrect.


Not only, on Linux for example you get if the file has wrong permissions (i actually struggled with that). You also get if you have ScriptAlias defined plus ExecCGI, the system then trys to run CGI via CGI (twice). This error has been a long time in the Xampp configuration (or it is still present), but i dont know if we are dealing with a Xampp installation?! Finally, what is this exam2.py?

Anyway, i succeded to run that Python Script without Apache Error, but it still does not run correctly as there are lots of syntax (Python) errors in that script, most obvious for example method "connector" with 3 n ("connnector").
Nobbie
 
Posts: 13179
Joined: 09. March 2008 13:04


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 184 guests