submodules.Popen拒绝运行命令,即使os.system工作正常

时间:2014-07-25 00:13:12

标签: python gruntjs subprocess popen

每当我运行此脚本时:

import subprocess

process = subprocess.Popen(['grunt', 'build'], stdout=subprocess.PIPE)

我一直都会遇到这个错误:

Traceback (most recent call last):
  File "test_grunt_fail.py", line 3, in <module>
    process = subprocess.Popen(['grunt', 'build'], 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

但是,grunt肯定已安装,因为我可以从命令行运行grunt build而不会出现任何问题,并在程序中运行os.system("grunt build")

鉴于此,os.system()为什么会在subprocess.Popen()不起作用?

0 个答案:

没有答案