我试图让一个 Popen 命令在带有 shell=False 的 Windows 上运行,而对于我的生活,我无法让它工作。iTMSTransporter 是一个命令行应用程序。这是我当前的代码:
import os
import shlex
import subprocess
from subprocess import Popen, PIPE, STDOUT
link = "C:/progra~1/itms/iTMSTransporter"
link1 = os.path.normpath(link)
link2 = "C:/Temp/test1.itmsp"
link3 = os.path.normpath(link2)
link4 = os.path.join(link3, "LogFile.txt")
command = link1 + " -m verify -f " + link3 +" -u username -p password -o " + link4 + " -s provider -v eXtreme"
process = Popen(shlex.split(command), shell=False, stdin=PIPE)
这给了我错误:
Traceback (most recent call last):
File "C:\Temp\temp.py", line 13, in <module>
process = Popen(shlex.split(command), shell=False, stdin=PIPE)
File "C:\Python27\lib\subprocess.py", line 709, in __init__
errread, errwrite)
File "C:\Python27\lib\subprocess.py", line 957, in _execute_child
startupinfo)
WindowsError: [Error 2] The system cannot find the file specified
我确定 progra~1 不是问题,因为它适用于 shell=True,并且还尝试了 Program Files,结果相同。有什么想法可以在 Windows 平台 Python 2.7 上运行吗?