命令通过终端工作,但不通过python系统调用

命令通过终端工作,但不通过python系统调用,python,system,subprocess,pipe,Python,System,Subprocess,Pipe,我试图从python代码对Boxer文本解析器程序进行系统调用,发现以下语句集不起作用。它没有给我任何错误,但我没有看到任何创建的输出文件。当我在终端上运行相同的命令时,会创建输出文件 from subprocess import call candcStr = 'echo "Every Man Walks" | /home/candc-1.00/bin/candc --models /home/candc-1.00/models/boxer --output /tmp/test.ccg' a

我试图从python代码对Boxer文本解析器程序进行系统调用,发现以下语句集不起作用。它没有给我任何错误,但我没有看到任何创建的输出文件。当我在终端上运行相同的命令时,会创建输出文件

from subprocess import call
candcStr = 'echo "Every Man Walks" | /home/candc-1.00/bin/candc --models /home/candc-1.00/models/boxer --output /tmp/test.ccg' 
args = shlex.split(candcStr)
call(args)
当我运行上述代码时,控制台显示

Every Man Walks | /home/candc-1.00/bin/candc --models /home/candc-1.00/models/boxer --output /tmp/test.ccg

管道重定向似乎不起作用。有人知道我怎么解决这个问题吗?谢谢

您需要为shell设置
shell=True
,以解释命令,最重要的是管道:

call(args, shell=True)

@AshwiniChaudhary谢谢,这很有效!!