Python异常错误:子进程文件丢失 - 但是是哪个文件?

3
我有一段运行在Python 2.7.3(Windows)上的代码,现在想在Python 2.7.8(Windows)上运行该代码,但遇到以下错误:
main: INFO ** Starting Main **
Traceback (most recent call last):
  File "C:\wamp\www\prenderer\src\main.py", line 82, in <module>
    nuke_process = launch_nuke()
  File "C:\wamp\www\prenderer\src\main.py", line 31, in launch_nuke
    query = subprocess.Popen(r"query process", stdout=subprocess.PIPE)
  File "F:\python27\lib\subprocess.py", line 710, in __init__
    errread, errwrite)
  File "F:\python27\lib\subprocess.py", line 958, in _execute_child
    startupinfo)
WindowsError: [Error 2] The system cannot find the file specified
>>> 

有什么问题吗?

1个回答

4

传递shell=True参数:

query = subprocess.Popen(r"query process", stdout=subprocess.PIPE, shell=True)

或者将命令行参数作为一个列表传递:

query = subprocess.Popen(["query", "process"], stdout=subprocess.PIPE)

否则查询过程会被认为是一个程序而不是查询

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接