0
我想運行現有的python代碼,並且遇到問題。如何在windows xp上正確使用subproces.Popen? - 在訪問npm時顯示windowserror 2
該程序需要安裝npm程序,並安裝在我的電腦的C:\ Program Files \ nodejs \ npm中。當我運行下面的代碼時,作爲整個程序的一部分,它會引發錯誤。
def popen_results(args):
proc = subprocess.Popen(args, stdout=subprocess.PIPE)
return proc.communicate()[0]
def installed():
"""docstring for npm_installed"""
return popen_results(["which", "npm"]).strip()
這是錯誤的thrown--
Checking for node and dependencies
Traceback (most recent call last):
File "deploy\deploy.py", line 344, in <module>
main()
File "deploy\deploy.py", line 287, in main
if not check_deps():
File "deploy\deploy.py", line 201, in check_deps
return npm.check_dependencies()
File "C:\Documents and Settings\Sunil\workspace\khan\src\deploy\npm.py", line
38, in check_dependencies
if not installed():
File "C:\Documents and Settings\Sunil\workspace\khan\src\deploy\npm.py", line
13, in installed
return popen_results(["which", "npm"]).strip()
File "C:\Documents and Settings\Sunil\workspace\khan\src\deploy\npm.py", line
8, in popen_results
proc = subprocess.Popen(args, stdout=subprocess.PIPE)
File "C:\python25\lib\subprocess.py", line 594, in __init__
errread, errwrite)
File "C:\python25\lib\subprocess.py", line 822, in _execute_child
startupinfo)
WindowsError: [Error 2] The system cannot find the file specified
在我看來就像它找不到'which'命令。 – martineau 2012-02-20 18:41:48