Call Python script from php with exec()

时间:2015-06-30 13:34:10

标签: php python

I have one python script for handling outlook emails using Outlook MAPI. I have to call this script from PHP code. If I call script from cmd it is fine, but when I do it from PHP doesn't work and there are no errors. Also if I just call some other python script with simple file writing code from same PHP script it works. I have no idea what to do. I am trying with exec('python c:/xampp/SCRIPT_LOCATION/SCRIPT.py') as well as shell_exec(), system()... but with no progression.

1 个答案:

答案 0 :(得分:0)

试试这个:

$python = 'C:\\Python27\\python.exe';
$pyscript = 'C:\\xampp\\SCRIPT_LOCATION\\SCRIPT.py';

exec("$python $pyscript");