我正在执行一个简单的 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());
}
但我得到了异常(exception):
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 运行相同的命令,一切正常。
最佳答案
改变
$process = new Process(['phyton -v']);
到
$process = new Process(['phyton', '-v']);
引用。 https://symfony.com/doc/current/components/process.html#usage
关于php - 从 Symfony 进程执行 python 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56064932/