Issue
I have a php code that run pyhton code but is not working os: fedora 38 server: localhost using apache
$command = 'py testCODES.py';
$output = shell_exec($command.' 2>&1');
it gives me this error
No executable found for Python
any solutions?
i tried solutions these commands:
sudo chown -R apache:apache /var/www/
sudo chmod -R 755 /var/www
sudo chmod +x *.py
Solution
It looks like when PHP runs shell_exec(…)
, it doesn't have access to the $PATH
env var that contain a list of directories that contain the executables.
One way to avoid this issue is to provide full paths so that the shell doesn't have to guess the locations of files:
/usr/bin/python /var/www/[…]/testCODES.py
You can run whereis python
to find where is the binary.
Answered By - A.L Answer Checked By - Marie Seifert (WPSolving Admin)