使用Python Subprocess将命令行发送到命令提示符[错误2:系统找不到指定的文件]

时间:2016-07-15 20:36:26

标签: python command-prompt popen

我正在尝试向命令提示符(终端)发送命令行并读取输出但我一直收到错误:

self get_version(self) 
File <folder path of my script>, line 39, in get_version
stdout = subprocess.PIPE
File "C:\Python27\lib\subprocess.py", line 710, in __init__
errread, errwrite)
File "C:\Python27\lib\subprocess.py", line 958, in _execute_child
startupinfo)
WindowsError: [Error 2] The system cannot find the file specified

这是我的代码:

import subprocess

def get_version(self)
    command = "wmic datafile where name='c:\\Drivers\\current_version\\GenericDriverSetup.exe' get version"
    proc = subprocess.Popen([command], 
    stdout=subprocess.PIPE)

    stdout_value = proc.communicate()[0]
    print '\tstdout:', repr(stdout_value)

有人可以告诉我这有什么问题吗?非常感谢

0 个答案:

没有答案