1

I need help to figure out how to run a python file from php script. Can someone let me know the complete procedure how to run a python file from php.

Appreciating your help.

1 Answer 1

1

Here is simple solution

/*
<complete path of python> '/usr/local/bin/python3';
<python file> 'test.py';
*/

$file_path = '<complete path of python> <python file>';

$command = escapeshellcmd($file_path);
$output = shell_exec($command);

var_dump($output);

let me know, if you face any other issue. Happy coding

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.