php - 从 Symfony 进程执行 python 失败
问题描述
我正在执行一个简单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 运行相同的命令,一切正常。
解决方案
改变
$process = new Process(['phyton -v']);
至
$process = new Process(['phyton', '-v']);
参考。https://symfony.com/doc/current/components/process.html#usage
推荐阅读
- javascript - 如何在 html 输入字段中的 2 个和 3 个字符后插入空格?
- c++ - “指针名称”未命名类型错误
- python - 我可以在 C++ 中使用字符串作为注释吗?
- swift - NSManagedObject 子类需要可编码编码器?
- android - 无法在片段内显示谷歌地图
- python - ImportError:无法导入名称转换
- python - 使用“And”条件删除与多列中特定字符串匹配的行
- java - 这个for循环有什么错误>> java netbeans
- html - 选择表单不显示选项预览
- jenkins - 从 GitLab 管道阶段触发 Jenkins 作业并在成功完成作业后移至下一阶段