0

I've researched this on Stackoverflow and other sites but I can't get it to work. I have WAMPSERVER 3.2.3 ruuning under Win10 on my desktop PC; PHP version 7.3.21, MySQL 5.7.31 and Apache 2.4.26. WAMPSERVER is installed on the C: drive in c:\wamp64, localhost is H:\sites.web. I've installed Python under C:\Python3.9 and I can use it from the command line. I downloaded mod_wsgi-4.7.1-cp39-cp39-win_amd64. whl and installed it using pip but didn't end up with a mod_wsgi.so file. I made the following changes to the Apache http.conf file

<Directory "${SRVROOT}/cgi-bin">
    AllowOverride None
    Options None
    Require all granted <- changed to granted from denied
</Directory>

added +ExecCGI to this line

Options +Indexes +FollowSymLinks +Multiviews +ExecCGI

and added .py to this line

AddHandler cgi-script .cgi .py

as per this Youtube video https://www.youtube.com/watch?v=N3XfGXi4ifE

But when I come to running a python script under localhost it doesn't work. Am I missing something? I get an error message that I don't have permsision to run that script.

Thanks

Paul

Paul Mc
  • 1
  • 3
  • Does your Apache process have C:\Python3.9 in its PATH? It needs to be able to find the interpreter. Have you added it to the global PATH? – Tim Roberts Mar 03 '21 at 19:06
  • Yes, C:\Python3.9 is included in the PATH. I tried a sample file from the python install beer.py; it runs in a quickly opened and closed dos window when I click on it. I copied it to a directory in localhost and tried to execute it from a browser and got "You don't have permission to access this resource." The first line (the shebang line apparently) of beer.py is #!/usr/bin/env python3, should it be different when executed from a browser? – Paul Mc Mar 04 '21 at 08:53
  • Or should python be installed in c:\wamp64\bin along with the php, mysql and apache executables? – Paul Mc Mar 04 '21 at 09:09
  • My apache error log says [cgi:error] [pid 6176:tid 1252] [client 127.0.0.1:50408] AH02809: Options ExecCGI is off in this directory: H:/sites.web/pythonTest/beer.py, referer: http://localhost/pythonTest/ – Paul Mc Mar 04 '21 at 09:40
  • Well, then, you'd better turn it on. ;) You can put Options ExecCGI in the .htaccess file in that folder. The #! lines are ignored on Windows. – Tim Roberts Mar 04 '21 at 17:52
  • Hi Tim, Tried that earlier today and got the follwoing error The server encountered an internal error or misconfiguration and was unable to complete your request. Please contact the server administrator at [email protected] to inform them of the time this error occurred, and the actions you performed just before this error. More information about this error may be available in the server error log. – Paul Mc Mar 04 '21 at 22:12
  • The apache error log says [Thu Mar 04 22:12:13.100890 2021] [cgi:error] [pid 16736:tid 1260] (OS 2)The system cannot find the file specified. : [client 127.0.0.1:59409] couldn't create child process: 720002: beer.py [Thu Mar 04 22:12:13.100890 2021] [cgi:error] [pid 16736:tid 1260] (OS 2)The system cannot find the file specified. : [client 127.0.0.1:59409] AH01223: couldn't spawn child process: H:/sites.web/pythonTest/beer.py – Paul Mc Mar 04 '21 at 22:15
  • You have AllowOverride off here, which means you can't put options in cgi-bin.. HOWEVER, the error says you're trying to run pythonTest/beer.py. That's not in cgi-bin. What URL are you trying to look at? – Tim Roberts Mar 05 '21 at 00:57
  • H:/sites.web is my localhost, so the URL I'm entering is localhost/pythonTest/beer.py – Paul Mc Mar 05 '21 at 09:15
  • OK, but then you have to have a specific section in your http.conf file that configures the pythonTest directory. The section you quoted above is for cgi-bin, which has nothing to do with pythonTest. You COULD have a section for your root, which gets inherited by the subdirectories. – Tim Roberts Mar 05 '21 at 19:20
  • Pos DUP https://stackoverflow.com/questions/8266153/how-to-install-python-with-wampserver – RiggsFolly Mar 06 '21 at 15:14
  • Hi Tim, to be honest I don't understand what you are telling me to do, what does this section for the root look like? Thanks – Paul Mc Mar 07 '21 at 15:53
  • Hi RiggsFolly, I don't think this is a duplication of the other post, that post was made 9 years ago and from what I can see the instructions for getting Python running under Wampserver have changed, I saw the post you refered to and tried everything in it but still can't get it to work. – Paul Mc Mar 07 '21 at 15:57

0 Answers0