奇怪的Python subrprocess.check_output行为

时间:2015-11-30 12:23:19

标签: python subprocess

我有以下Python代码:

import visa 
import os
import subprocess
#import Enum


def enum(**named_values):
   return type('Enum', (), named_values)

InstrumentSelect = enum(RS_Spectrum_Analyser = 'Spectrum', Oscilloscope = 'Oscilloscope')


outp = subprocess.check_output(['C:\Temp\RsSpecExample.exe',InstrumentSelect.RS_Spectrum_Analyser])
print outp
outp = subprocess.check_output(['C:\Temp\RsSpecExample.exe', ])
print outp

当我第一次运行它时它运行得非常好,我从.exe中的简单C#应用程序中获得了正确的返回值。

第二次尝试运行脚本时,我得到以下行为:

 File "C:/Users/eoco/PycharmProjects/untitled/main", line 49, in <module>
outp = subprocess.check_output(['C:\Temp\RsSpecExample.exe',InstrumentSelect.RS_Spectrum_Analyser])
 File "C:\WinPython-64bit-2.7.9.4\python-2.7.9.amd64\lib\subprocess.py", line 566, in check_output
process = Popen(stdout=PIPE, *popenargs, **kwargs)
 File "C:\WinPython-64bit-2.7.9.4\python-2.7.9.amd64\lib\subprocess.py", line 710, in __init__errread, errwrite)
 File "C:\WinPython-64bit-2.7.9.4\python-2.7.9.amd64\lib\subprocess.py", line 958, in _execute_child
startupinfo)
WindowsError: [Error 2] The system cannot find the file specified

当我检查C:驱动器中的文件夹时,exe现在已经消失,我似乎不再拥有该文件夹的写入权限。

有什么想法吗?

0 个答案:

没有答案