在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
当我在终端中运行相同的命令时,它可以工作,文件肯定存在。
答案 0 :(得分:0)
您缺少2个"
,,
Popen
会获取参数列表。试试这个:
from subprocess import Popen
Popen(["nohup", "/usr/local/bin/python2.7", "/somescript.py"])