Running Python within PHP works within the CLI but not the XAMPP server

I have this Python script to use within a PHP page, and I have found out the code for PHP to run it. This is my code:
<?php
$command = '3.8/bin/python3 googleNewsScraper.py CNN';
$output = exec($command, $output, $status);
echo $status;
echo $output;
?>
When I use the commandphp index.php
, it works fine and echos out the output of the command, which is good. But, it doesn't output anything on my XAMPP local server, so I echo'ed the status. When I use the full path to the python interpreter, it gives me 127, which is because it doesn't know that command. But, with the current command as shown above, I get a status of 2. I have tried using the full path to each file, tried using a simple file that can't return errors, tried editinghttpd.conf
to includeAddHandler cgi-script .py
, restarted XAMPP multiple times, but nothing is happening or working.
Just to be clear, I am 100% sure that this is not a problem with paths as I was able to print out the contents of the file using the exact same path (just used the commandecho file_get_contents("googleNewsScraper.py");
. Any help is greatly appreciated.
EDIT: I checked the error log and this is the error that is occurring:
[Mon Jun 29 05:44:17.177250 2020] [core:notice] [pid 652] AH00094: Command line: '/opt/lampp/bin/httpd -E /opt/lampp/logs/error_log -D SSL -D PHP'
sh: 1: 3.8/bin/python3: Exec format error
EDIT 2: If I use the full path I get this error:
sh: 1: /Users/rosen59250/.bitnami/stackman/machines/xampp/volumes/root/htdocs/PHP API Page/3.8/bin/python3: not found
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: the payload is invalid.
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.