Popen在尝试执行脚本时在python中给出错误

时间:2017-03-30 15:54:50

标签: python debian popen

在python中遇到Popen问题。有问题的代码:

from subprocess import Popen
Popen(["nohup", "/usr/local/bin/python2.7  /somescript.py"])

出现以下错误:

 failed to run command `/usr/local/bin/python2.7  /somescript.py': No such file or directory

当我在终端中运行相同的命令时,它可以工作,文件肯定存在。

1 个答案:

答案 0 :(得分:0)

您缺少2个", Popen会获取参数列表。试试这个:

from subprocess import Popen
Popen(["nohup", "/usr/local/bin/python2.7",  "/somescript.py"])