python2.7 / subprocess.py,第1335行,在_execute_child中引发child_exception OSError:[Errno 2]没有这样的文件或目录

时间:2017-06-22 11:54:26

标签: python python-2.7 perl subprocess

我的代码:

tokenizer_cmd = ['/home/liuww/wangt/ssvae/scripts/tokenizer/tokenizer.perl', '-l', 'en', '-q', '-']
def tokenize(sentences):
    print 'Tokenizing..',
    text = "\n".join(sentences)
    tokenizer = Popen(tokenizer_cmd, stdin=PIPE, stdout=PIPE)
    tok_text, _ = tokenizer.communicate(text)
    toks = tok_text.split('\n')[:-1]
    print 'Done'

    return toks
sentences = tokenize(sentences)

当我运行上面的代码时,出现错误:

File "imdb_preprocess.py", line 67, in build_dict
sentences = tokenize(sentences)
File "imdb_preprocess.py", line 35, in tokenize
tokenizer = Popen(tokenizer_cmd, stdin=PIPE, stdout=PIPE)
File "/home/liuww/anaconda2/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/home/liuww/anaconda2/lib/python2.7/subprocess.py", line 1335, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory

但命令的第一项是真正的目录,即'/home/liuww/wangt/ssvae/scripts/tokenizer/tokenizer.perl'。

我发现了许多答案,但它们并没有用。希望每个有这个问题的人都可以帮助我。非常感谢!

0 个答案:

没有答案