时,当我在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