我想從python本身運行子進程的praat文件,但python(子進程)似乎無法找到目錄。我不明白爲什麼當我在終端中運行命令時,它工作得很好。任何人都不能指導我去哪裏錯了? 這是子碼python中的子進程錯誤
import silex
import subprocess as sb
cmd_line = raw_input()
args = shlex.split(cmd_line)
p = sb.Popen(args)
當我輸入運行
Praat /Users/admirmonteiro/tmp/tmp.praat
這是我的錯誤:
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/Users/admirmonteiro/anaconda/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/Users/admirmonteiro/anaconda/lib/python2.7/subprocess.py", line 1335, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
如前所述,我運行的命令和他們在終端上運行良好。 我也想跑subprocess.call但發生同樣的錯誤。我也嘗試過使用shell = True作爲參數,但也輸出相同的錯誤。 請幫忙!
手動運行時哪個'Praat'返回什麼? –
如果我自己輸入它,它會打開應用程序。如果我像上面提到的那樣用文件打開它,它會運行返回另一個文件的文件。如果我在終端上這樣做,它會起作用。 – Aboogie
另外,當我運行subprocess.call([Praat「])時,我得到了錯誤:call([」Praat「],shell = True) /bin/sh:Praat:command not found 127這是沒有意義的,當我在終端運行Praat時,它工作正常,我很困惑 – Aboogie