Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/280.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/tfs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python subprocess.Popen不打开exe_Python_Command Line - Fatal编程技术网

Python subprocess.Popen不打开exe

Python subprocess.Popen不打开exe,python,command-line,Python,Command Line,这项工作: FNULL = open(os.devnull, 'w') sgargs = "C:\\Program Files (x86)\\Stone Giant\\exe\\stone_giant.exe -bundle-dir \"C:\\Program Files (x86)\\Stone Giant\\bundle\"" subprocess.call(sgargs, stdout=FNULL, stderr=FNULL, shell=False) 这不起作用,也不会给出任何错误或信

这项工作:

FNULL = open(os.devnull, 'w')
sgargs = "C:\\Program Files (x86)\\Stone Giant\\exe\\stone_giant.exe -bundle-dir \"C:\\Program Files (x86)\\Stone Giant\\bundle\""
subprocess.call(sgargs, stdout=FNULL, stderr=FNULL, shell=False)
这不起作用,也不会给出任何错误或信息:

subprocess.Popen(["C:\\Program Files (x86)\\Stone Giant\\exe\\stone_giant.exe", "-bundle-dir \"C:\\Program Files (x86)\\Stone Giant\\bundle\""])

我想使用Popen,这样它就不会阻塞。我遗漏了什么?

在第二个示例中,您将
-bundle dir\“C:\\Program Files(x86)\\Stone Giant\\bundle\
作为一个单独的参数。在引擎盖下,python避开了参数名和值之间的空格,程序认为您传递了一个按字面意思命名的参数“-bundle dir\”C:\Program Files(x86)\巨石阵\捆绑\”

分为多个参数

["C:\\Program Files (x86)\\Stone Giant\\exe\\stone_giant.exe", 
    "-bundle-dir", "C:\\Program Files (x86)\\Stone Giant\\bundle\"]

您将bundle dir设置为单个参数,可能希望
[“C:\\Program Files(x86)\\Stone Giant\\exe\\Stone\u Giant.exe”、“-bundle dir”、“C:\\Program Files(x86)\\Stone Giant\\bundle\”]
(分开参数)起作用!非常感谢。顺便说一句,虽然您的第一个示例中的shell=False在Windows上工作(所有内容都通过shell),但它在linux上不工作。出于某种原因,Popen正在为我阻止。除非我杀死stone_giant.exe,否则我的代码不会继续。我使用的是python 2.7。我是否在Popen中丢失了更多参数?只要您不再对Popen对象上的方法进行任何调用,它就不应该阻止。如果您试图完全退出父级,并且没有一台windows计算机可用于tes,我不确定windows上会发生什么。t抱歉,我犯了一个错误,忘记取消注释我先前的
调用
代码。现在很好用。谢谢