Windowssubprocess。打开一个没有shell = True的batch file

我有一个运行lessc的函数(使用npm install -g less ):

 >>> import subprocess >>> subprocess.Popen(['lessc']) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Python27\lib\subprocess.py", line 679, in __init__ errread, errwrite) File "C:\Python27\lib\subprocess.py", line 896, in _execute_child startupinfo) WindowsError: [Error 2] The system cannot find the file specified 

不幸的是,除非我添加shell=True ,否则不起作用:

 >>> subprocess.Popen(['lessc'], shell=True) <subprocess.Popen object at 0x01F619D0> 

我能做些什么来让lessc运行而不使用shell=True

Solutions Collecting From Web of "Windowssubprocess。打开一个没有shell = True的batch file"