简体   繁体   中英

Call Python script from php with exec()

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.

Try this:

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

exec("$python $pyscript");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM