从Symfony进程执行python失败

时间:2019-05-09 17:47:25

标签: php python linux symfony

我正在执行以下简单的python -v

$process = new Process(['python -v']);
$process->run();

try {
      if (!$process->isSuccessful()) 
      {
        throw new ProcessFailedException($process);
      }
     }
      catch (\Exception $e) {
            $this->logger->error($e->getMessage());
     }

但我得到了例外:

The command "'python -v'" failed.  Exit Code: 127(Command not found)  Working directory: /var/www/symfony/symfony/public  Output: ================   Error Output: ================ sh: 1: exec: python -v: not found

如果我从外壳程序运行相同的命令,则一切正常。

1 个答案:

答案 0 :(得分:1)

更改

$process = new Process(['phyton -v']);

$process = new Process(['phyton',  '-v']);

参考this