【问题标题】:Execute python from Symfony Process fails从 Symfony 进程执行 python 失败
【发布时间】:2019-05-09 17:47:24
【问题描述】:

我正在执行一个简单的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

如果我从 shell 运行相同的命令,一切正常。

【问题讨论】:

    标签: php python linux symfony


    【解决方案1】:

    改变

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

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

    参考。 https://symfony.com/doc/current/components/process.html#usage

    【讨论】:

    • 您的意思是python 而不是phyton
    猜你喜欢
    • 2010-12-21
    • 2017-08-15
    • 1970-01-01
    • 2017-02-04
    • 2021-06-08
    • 1970-01-01
    • 2015-02-24
    • 2020-10-09
    • 1970-01-01
    相关资源
    最近更新 更多