Running Python scripts with Xampp
I'm using python 2.7.13
At first the browser was showing the raw code.
what I did:
Edited httpd.conf
AddHandler cgi-script .cgi .pl .asp .py
At the top of all my scripts I added this:
#!j:/Installeds/Python/python
print "Content-type: text/htmlnn"
Now it's giving me Internal Server Error (500)
and I have no idea what else to try... First time with python.
Obs: I think this may help> Apache>Error.log
[cgi:error] [pid 6364:tid 1620] (9)Bad file descriptor: [client ::1:51083] AH01222: don't know how to spawn child process: C:/Files and Installs/Xampp/htdocs/Test/main.py
AH02102: C:/Files and Installs/Xampp/htdocs/Test/main.py is not executable; ensure interpreted scripts have "#!" or "'!" first line
python apache xampp
add a comment |
I'm using python 2.7.13
At first the browser was showing the raw code.
what I did:
Edited httpd.conf
AddHandler cgi-script .cgi .pl .asp .py
At the top of all my scripts I added this:
#!j:/Installeds/Python/python
print "Content-type: text/htmlnn"
Now it's giving me Internal Server Error (500)
and I have no idea what else to try... First time with python.
Obs: I think this may help> Apache>Error.log
[cgi:error] [pid 6364:tid 1620] (9)Bad file descriptor: [client ::1:51083] AH01222: don't know how to spawn child process: C:/Files and Installs/Xampp/htdocs/Test/main.py
AH02102: C:/Files and Installs/Xampp/htdocs/Test/main.py is not executable; ensure interpreted scripts have "#!" or "'!" first line
python apache xampp
add a comment |
I'm using python 2.7.13
At first the browser was showing the raw code.
what I did:
Edited httpd.conf
AddHandler cgi-script .cgi .pl .asp .py
At the top of all my scripts I added this:
#!j:/Installeds/Python/python
print "Content-type: text/htmlnn"
Now it's giving me Internal Server Error (500)
and I have no idea what else to try... First time with python.
Obs: I think this may help> Apache>Error.log
[cgi:error] [pid 6364:tid 1620] (9)Bad file descriptor: [client ::1:51083] AH01222: don't know how to spawn child process: C:/Files and Installs/Xampp/htdocs/Test/main.py
AH02102: C:/Files and Installs/Xampp/htdocs/Test/main.py is not executable; ensure interpreted scripts have "#!" or "'!" first line
python apache xampp
I'm using python 2.7.13
At first the browser was showing the raw code.
what I did:
Edited httpd.conf
AddHandler cgi-script .cgi .pl .asp .py
At the top of all my scripts I added this:
#!j:/Installeds/Python/python
print "Content-type: text/htmlnn"
Now it's giving me Internal Server Error (500)
and I have no idea what else to try... First time with python.
Obs: I think this may help> Apache>Error.log
[cgi:error] [pid 6364:tid 1620] (9)Bad file descriptor: [client ::1:51083] AH01222: don't know how to spawn child process: C:/Files and Installs/Xampp/htdocs/Test/main.py
AH02102: C:/Files and Installs/Xampp/htdocs/Test/main.py is not executable; ensure interpreted scripts have "#!" or "'!" first line
python apache xampp
python apache xampp
edited Mar 9 '17 at 22:13
PlayHardGoPro
asked Mar 9 '17 at 20:31
PlayHardGoProPlayHardGoPro
1,00842349
1,00842349
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
Run Python in xampp for windows:
STEP-1:[Download Python]
Download & install the latest version of python from www.python.org Download Python & click on the windows installer of any version
[ex. python-3.6.2]
STEP 2: [Install Python]
Install in any directory of your harddrive
[ex. D:python-3.6.2]
STEP 3: [Configur Python]
Open the directory where xammp was installed
Go to apache >> conf
[ex. D:xamppapacheconfhttpd.conf]
You'll see a file named httpd.conf
Open it in any text editor & put the below codes in the end of that file
AddHandler cgi-script .py
ScriptInterpreterSource Registry-Strict
STEP 4:[optional]
In same file search for
When you've found it put index.py in the end
It will look something like this
<IfModule dir_module>
DirectoryIndex index.php index.pl index.cgi index.asp index.shtml index.html index.htm
default.php default.pl default.cgi default.asp default.shtml default.html default.htm
home.php home.pl home.cgi home.asp home.shtml home.html home.htm index.py
</IfModule>
STEP 5:[restart apache/xampp]
That's all for editing, now restart apache from your xampp control panel
STEP 6:[Run Python from xammp]
Open a text editor & test python now on xammp htdoc directory[ex. D:xampphtdocsPythonProject].
But wait at the beginning of your script you need to specify the path where you've installed python. In my case its D:/python-3.6.2/python.exe .In your case it may be different, depending up on the version you've installed python & the directory of your hard drive python Code .
#!D:/python-3.6.2/python.exe
print("Content-Type: text/htmln")
print ("Hello Python Web Browser!! This is cool!!")
or
#!C:/Users/YOUR_WINDOWS_PROFILE/AppData/Local/Programs/Python/Python37-32/python.exe
print("Content-Type: text/html")
print()
print ("""
<TITLE>CGI script ! Python</TITLE>
<H1>This is my first CGI script</H1>
""")
Save the file as test.py in htdocs & open http://localhost/PythonProjecttest.py .If everything goes well, You'll see the text "Hello Python Web Browser!! This is cool!!"
add a comment |
Im running ubuntu 16.04 so my answer might be a little different. I am using a google chrome browser with a python 3 file called test.py in /opt/lampp/htdocs/PythonProject:
#test.py
#!/usr/bin/env python3
print('Content-type: text/htmlrnr')
print("<p>hello world!</p>")
print("I can view this in my browser yay!!")
I edited my httpd.conf file in /opt/lampp/etc/httpd.conf and I did not add
AddHandler cgi-script .py
ScriptInterpreterSource Registry-Strict
to the end of the file, instead I added .py to the end of the existing line
AddHandler cgi-script .cgi .pl
finally i made the file executable by chmod +x /opt/lampp/htdocs/PythonProject/test.py
and then I just ran it through my browser:
http://localhost/PythonProject/test.py
OUTPUT:
hello world!
I can view this in my browser yay!!
Perfect! Works like a charm!
– ThePhi
Sep 7 '18 at 10:51
add a comment |
Bad File descriptor means that a file is corrupt and it says it can not run the script so you probably have python incorrectly set up.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f42704846%2frunning-python-scripts-with-xampp%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
Run Python in xampp for windows:
STEP-1:[Download Python]
Download & install the latest version of python from www.python.org Download Python & click on the windows installer of any version
[ex. python-3.6.2]
STEP 2: [Install Python]
Install in any directory of your harddrive
[ex. D:python-3.6.2]
STEP 3: [Configur Python]
Open the directory where xammp was installed
Go to apache >> conf
[ex. D:xamppapacheconfhttpd.conf]
You'll see a file named httpd.conf
Open it in any text editor & put the below codes in the end of that file
AddHandler cgi-script .py
ScriptInterpreterSource Registry-Strict
STEP 4:[optional]
In same file search for
When you've found it put index.py in the end
It will look something like this
<IfModule dir_module>
DirectoryIndex index.php index.pl index.cgi index.asp index.shtml index.html index.htm
default.php default.pl default.cgi default.asp default.shtml default.html default.htm
home.php home.pl home.cgi home.asp home.shtml home.html home.htm index.py
</IfModule>
STEP 5:[restart apache/xampp]
That's all for editing, now restart apache from your xampp control panel
STEP 6:[Run Python from xammp]
Open a text editor & test python now on xammp htdoc directory[ex. D:xampphtdocsPythonProject].
But wait at the beginning of your script you need to specify the path where you've installed python. In my case its D:/python-3.6.2/python.exe .In your case it may be different, depending up on the version you've installed python & the directory of your hard drive python Code .
#!D:/python-3.6.2/python.exe
print("Content-Type: text/htmln")
print ("Hello Python Web Browser!! This is cool!!")
or
#!C:/Users/YOUR_WINDOWS_PROFILE/AppData/Local/Programs/Python/Python37-32/python.exe
print("Content-Type: text/html")
print()
print ("""
<TITLE>CGI script ! Python</TITLE>
<H1>This is my first CGI script</H1>
""")
Save the file as test.py in htdocs & open http://localhost/PythonProjecttest.py .If everything goes well, You'll see the text "Hello Python Web Browser!! This is cool!!"
add a comment |
Run Python in xampp for windows:
STEP-1:[Download Python]
Download & install the latest version of python from www.python.org Download Python & click on the windows installer of any version
[ex. python-3.6.2]
STEP 2: [Install Python]
Install in any directory of your harddrive
[ex. D:python-3.6.2]
STEP 3: [Configur Python]
Open the directory where xammp was installed
Go to apache >> conf
[ex. D:xamppapacheconfhttpd.conf]
You'll see a file named httpd.conf
Open it in any text editor & put the below codes in the end of that file
AddHandler cgi-script .py
ScriptInterpreterSource Registry-Strict
STEP 4:[optional]
In same file search for
When you've found it put index.py in the end
It will look something like this
<IfModule dir_module>
DirectoryIndex index.php index.pl index.cgi index.asp index.shtml index.html index.htm
default.php default.pl default.cgi default.asp default.shtml default.html default.htm
home.php home.pl home.cgi home.asp home.shtml home.html home.htm index.py
</IfModule>
STEP 5:[restart apache/xampp]
That's all for editing, now restart apache from your xampp control panel
STEP 6:[Run Python from xammp]
Open a text editor & test python now on xammp htdoc directory[ex. D:xampphtdocsPythonProject].
But wait at the beginning of your script you need to specify the path where you've installed python. In my case its D:/python-3.6.2/python.exe .In your case it may be different, depending up on the version you've installed python & the directory of your hard drive python Code .
#!D:/python-3.6.2/python.exe
print("Content-Type: text/htmln")
print ("Hello Python Web Browser!! This is cool!!")
or
#!C:/Users/YOUR_WINDOWS_PROFILE/AppData/Local/Programs/Python/Python37-32/python.exe
print("Content-Type: text/html")
print()
print ("""
<TITLE>CGI script ! Python</TITLE>
<H1>This is my first CGI script</H1>
""")
Save the file as test.py in htdocs & open http://localhost/PythonProjecttest.py .If everything goes well, You'll see the text "Hello Python Web Browser!! This is cool!!"
add a comment |
Run Python in xampp for windows:
STEP-1:[Download Python]
Download & install the latest version of python from www.python.org Download Python & click on the windows installer of any version
[ex. python-3.6.2]
STEP 2: [Install Python]
Install in any directory of your harddrive
[ex. D:python-3.6.2]
STEP 3: [Configur Python]
Open the directory where xammp was installed
Go to apache >> conf
[ex. D:xamppapacheconfhttpd.conf]
You'll see a file named httpd.conf
Open it in any text editor & put the below codes in the end of that file
AddHandler cgi-script .py
ScriptInterpreterSource Registry-Strict
STEP 4:[optional]
In same file search for
When you've found it put index.py in the end
It will look something like this
<IfModule dir_module>
DirectoryIndex index.php index.pl index.cgi index.asp index.shtml index.html index.htm
default.php default.pl default.cgi default.asp default.shtml default.html default.htm
home.php home.pl home.cgi home.asp home.shtml home.html home.htm index.py
</IfModule>
STEP 5:[restart apache/xampp]
That's all for editing, now restart apache from your xampp control panel
STEP 6:[Run Python from xammp]
Open a text editor & test python now on xammp htdoc directory[ex. D:xampphtdocsPythonProject].
But wait at the beginning of your script you need to specify the path where you've installed python. In my case its D:/python-3.6.2/python.exe .In your case it may be different, depending up on the version you've installed python & the directory of your hard drive python Code .
#!D:/python-3.6.2/python.exe
print("Content-Type: text/htmln")
print ("Hello Python Web Browser!! This is cool!!")
or
#!C:/Users/YOUR_WINDOWS_PROFILE/AppData/Local/Programs/Python/Python37-32/python.exe
print("Content-Type: text/html")
print()
print ("""
<TITLE>CGI script ! Python</TITLE>
<H1>This is my first CGI script</H1>
""")
Save the file as test.py in htdocs & open http://localhost/PythonProjecttest.py .If everything goes well, You'll see the text "Hello Python Web Browser!! This is cool!!"
Run Python in xampp for windows:
STEP-1:[Download Python]
Download & install the latest version of python from www.python.org Download Python & click on the windows installer of any version
[ex. python-3.6.2]
STEP 2: [Install Python]
Install in any directory of your harddrive
[ex. D:python-3.6.2]
STEP 3: [Configur Python]
Open the directory where xammp was installed
Go to apache >> conf
[ex. D:xamppapacheconfhttpd.conf]
You'll see a file named httpd.conf
Open it in any text editor & put the below codes in the end of that file
AddHandler cgi-script .py
ScriptInterpreterSource Registry-Strict
STEP 4:[optional]
In same file search for
When you've found it put index.py in the end
It will look something like this
<IfModule dir_module>
DirectoryIndex index.php index.pl index.cgi index.asp index.shtml index.html index.htm
default.php default.pl default.cgi default.asp default.shtml default.html default.htm
home.php home.pl home.cgi home.asp home.shtml home.html home.htm index.py
</IfModule>
STEP 5:[restart apache/xampp]
That's all for editing, now restart apache from your xampp control panel
STEP 6:[Run Python from xammp]
Open a text editor & test python now on xammp htdoc directory[ex. D:xampphtdocsPythonProject].
But wait at the beginning of your script you need to specify the path where you've installed python. In my case its D:/python-3.6.2/python.exe .In your case it may be different, depending up on the version you've installed python & the directory of your hard drive python Code .
#!D:/python-3.6.2/python.exe
print("Content-Type: text/htmln")
print ("Hello Python Web Browser!! This is cool!!")
or
#!C:/Users/YOUR_WINDOWS_PROFILE/AppData/Local/Programs/Python/Python37-32/python.exe
print("Content-Type: text/html")
print()
print ("""
<TITLE>CGI script ! Python</TITLE>
<H1>This is my first CGI script</H1>
""")
Save the file as test.py in htdocs & open http://localhost/PythonProjecttest.py .If everything goes well, You'll see the text "Hello Python Web Browser!! This is cool!!"
edited Nov 13 '18 at 4:00
community wiki
4 revs, 2 users 90%
matinict
add a comment |
add a comment |
Im running ubuntu 16.04 so my answer might be a little different. I am using a google chrome browser with a python 3 file called test.py in /opt/lampp/htdocs/PythonProject:
#test.py
#!/usr/bin/env python3
print('Content-type: text/htmlrnr')
print("<p>hello world!</p>")
print("I can view this in my browser yay!!")
I edited my httpd.conf file in /opt/lampp/etc/httpd.conf and I did not add
AddHandler cgi-script .py
ScriptInterpreterSource Registry-Strict
to the end of the file, instead I added .py to the end of the existing line
AddHandler cgi-script .cgi .pl
finally i made the file executable by chmod +x /opt/lampp/htdocs/PythonProject/test.py
and then I just ran it through my browser:
http://localhost/PythonProject/test.py
OUTPUT:
hello world!
I can view this in my browser yay!!
Perfect! Works like a charm!
– ThePhi
Sep 7 '18 at 10:51
add a comment |
Im running ubuntu 16.04 so my answer might be a little different. I am using a google chrome browser with a python 3 file called test.py in /opt/lampp/htdocs/PythonProject:
#test.py
#!/usr/bin/env python3
print('Content-type: text/htmlrnr')
print("<p>hello world!</p>")
print("I can view this in my browser yay!!")
I edited my httpd.conf file in /opt/lampp/etc/httpd.conf and I did not add
AddHandler cgi-script .py
ScriptInterpreterSource Registry-Strict
to the end of the file, instead I added .py to the end of the existing line
AddHandler cgi-script .cgi .pl
finally i made the file executable by chmod +x /opt/lampp/htdocs/PythonProject/test.py
and then I just ran it through my browser:
http://localhost/PythonProject/test.py
OUTPUT:
hello world!
I can view this in my browser yay!!
Perfect! Works like a charm!
– ThePhi
Sep 7 '18 at 10:51
add a comment |
Im running ubuntu 16.04 so my answer might be a little different. I am using a google chrome browser with a python 3 file called test.py in /opt/lampp/htdocs/PythonProject:
#test.py
#!/usr/bin/env python3
print('Content-type: text/htmlrnr')
print("<p>hello world!</p>")
print("I can view this in my browser yay!!")
I edited my httpd.conf file in /opt/lampp/etc/httpd.conf and I did not add
AddHandler cgi-script .py
ScriptInterpreterSource Registry-Strict
to the end of the file, instead I added .py to the end of the existing line
AddHandler cgi-script .cgi .pl
finally i made the file executable by chmod +x /opt/lampp/htdocs/PythonProject/test.py
and then I just ran it through my browser:
http://localhost/PythonProject/test.py
OUTPUT:
hello world!
I can view this in my browser yay!!
Im running ubuntu 16.04 so my answer might be a little different. I am using a google chrome browser with a python 3 file called test.py in /opt/lampp/htdocs/PythonProject:
#test.py
#!/usr/bin/env python3
print('Content-type: text/htmlrnr')
print("<p>hello world!</p>")
print("I can view this in my browser yay!!")
I edited my httpd.conf file in /opt/lampp/etc/httpd.conf and I did not add
AddHandler cgi-script .py
ScriptInterpreterSource Registry-Strict
to the end of the file, instead I added .py to the end of the existing line
AddHandler cgi-script .cgi .pl
finally i made the file executable by chmod +x /opt/lampp/htdocs/PythonProject/test.py
and then I just ran it through my browser:
http://localhost/PythonProject/test.py
OUTPUT:
hello world!
I can view this in my browser yay!!
answered Jun 27 '18 at 18:01
wade kingwade king
1537
1537
Perfect! Works like a charm!
– ThePhi
Sep 7 '18 at 10:51
add a comment |
Perfect! Works like a charm!
– ThePhi
Sep 7 '18 at 10:51
Perfect! Works like a charm!
– ThePhi
Sep 7 '18 at 10:51
Perfect! Works like a charm!
– ThePhi
Sep 7 '18 at 10:51
add a comment |
Bad File descriptor means that a file is corrupt and it says it can not run the script so you probably have python incorrectly set up.
add a comment |
Bad File descriptor means that a file is corrupt and it says it can not run the script so you probably have python incorrectly set up.
add a comment |
Bad File descriptor means that a file is corrupt and it says it can not run the script so you probably have python incorrectly set up.
Bad File descriptor means that a file is corrupt and it says it can not run the script so you probably have python incorrectly set up.
answered Mar 9 '17 at 20:41
Noah CristinoNoah Cristino
594423
594423
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f42704846%2frunning-python-scripts-with-xampp%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown