Python Forum

Full Version: XAMPP Configuration of Python
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am starting to explore Python. I have downloaded the latest version of Python. Installed the same for all users and have tested it too

Output:
Python 3.11.2
Now I have also configured Python to my httpd.conf of XAMPP Apache by adding these lines.

AddHandler cgi-script .py
ScriptInterpreterSource Registry-Strict

index.py, default.py and home.py have been added as some of the default documents.

Now wrote a quick test .py script as below

print ("Hello World") and it worked fine on commandline.

Now running the same through XAMPP triggers an Internal Server Error and in the logs shows a message like

[Sun Mar 19 19:36:57.115244 2023] [win32:error] [pid 4872:tid 1896] [client ::1:57020] AH02102: C:/xampp/htdocs/index.py is not executable; ensure interpreted scripts have "#!" or "'!" first line
[Sun Mar 19 19:36:57.115244 2023] [cgi:error] [pid 4872:tid 1896] (9)Bad file descriptor: [client ::1:57020] AH01222: don't know how to spawn child process: C:/xampp/htdocs/index.py

Python is in the environmental variable and can be invoked from anywhere (for all users)
You should not use XAMPP with Python.
If do web-development in Python use eg Flask,Django...ect,these comes with build in web-server for local development.
(Mar-19-2023, 02:01 PM)lavanyadeepak Wrote: [ -> ]AddHandler cgi-script .py
ScriptInterpreterSource Registry-Strict
Should not setup Python for cgi-script as in Python is CGI dead💀.
Python community did write a own protocol WSGI.
Today is all Python framework build on top of WSGI.