简体   繁体   English

php exec()未运行python脚本

[英]php exec() not running python script

i run the python script bellow in the command line and it works fine, but when i execute it in a php file it returns an empty array. 我在命令行中运行下面的python脚本,它运行良好,但是当我在php文件中执行它时,它返回一个空数组。

python 蟒蛇

import sys

id_input=sys.argv[1] 

print id_input

php PHP

<?php


$out="";
exec("python teste.py a  ",$out);
print_r($out);

?>

output of php: array() php的输出:array()

output in command line: a 在命令行中输出:a

Both files are in the same directory and i am using XAMPP in Vista OS to run them. 这两个文件都在同一目录中,我在Vista OS中使用XAMPP来运行它们。

按照评论...问题是您需要指定python二进制文件的完整路径,因为PHP无法识别环境变量,例如PATH。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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