時,當我在CentOS的執行下面的功能,我得到錯誤蟒蛇:錯誤執行subprocess.popen
def install_requests_lib():
try:
import requests
return
except ImportError, e:
print "module does not exist, installing..."
if(platform.system().lower()=='darwin'):
print "install requests before proceeding, run **sudo pip install requests**"
sys.exit(2)
elif(platform.system().lower()=='linux'):
print "installing"
p=Popen(["yum","-y","install","python-requests"], stdout=PIPE, shell=True)
p.communicate()
print p.returncode
錯誤:
module does not exist, installing...
installing
You need to give some command
1
我想不通爲什麼它是錯誤的。
我用stdin=PIPE
參數執行,仍然得到相同的錯誤。
您的腳本是否有權執行'yum install'?您也可以將stderr重定向到stdout以查看所有輸出。 – grundic