用PHP执行Python

I try to execute this PHP command :

 $result = exec("sudo python /home/pi/test.py",$output, $ret);
 var_dump($result);
 echo "<br>";
 var_dump($output);
 echo "<br>";
 var_dump($ret);

This command works perfectly on a Linux Terminal but with the PHP it doesn't work.

Here the result on the PHP page :

string(0)
array(0) { }
int(9)

I verified the process with ps -ef, nothing appears.

It might be help someone with the same problem. I managed later to execute a Python script with this PHP code :

$command = escapeshellcmd('sudo /home/pi/test.py');
$output = shell_exec($command);
echo $output;

For the moment, I never succeed to execute this in background. I try those solutions :

$command = escapeshellcmd("sudo /home/pi/test.py >/dev/null &");

$command = escapeshellcmd("sudo /home/pi/test.py &");

My PHP page wait also the end of the process, but i don't want to.