AWS Elastic Beanstalk无法使用requirements.txt Git Pip安装Python包 [英] AWS Elastic Beanstalk failed to install Python package using requirements.txt Git Pip

查看:365
本文介绍了AWS Elastic Beanstalk无法使用requirements.txt Git Pip安装Python包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用 eb deploy 在AWS Elastic Beanstalk上部署Flask应用程序,但失败。



我在应用程序目录下有 requirements.txt

  Flask == 0.12.2 
numpy == 1.13.3
pandas == 0.21.1
requests == 2.18.4
scipy == 1.0.0
Werkzeug == 0.12.2
-e git + http://github.com/hensing/PyDDE#egg=PyDDE
.ebextensions 下的$ c>

python.config code>目录:

 包:
yum:
git:[]
gcc-c ++:[]
make:[]

错误信息是:


信息:环境更新开始。



信息:将新版本部署到实例(s)。



错误:您的requirements.txt无效。快照您的日志以获取详细信息。



错误:[实例:i-03e92fa3c58b6e010]命令在实例上失败。返回码:1输出:(截断)...


文件/usr/lib64/python2.7/subprocess.py,第541行,在check_call中



引发CalledProcessError(retcode,cmd)



CalledProcessError:Command'/ opt / python / run / venv / bin / pip install -r / opt / python / ondeck / app / requirements
.txt'返回非零退出状态2。



Hook /opt/elasticbeanstalk/hooks/appdeploy/pre/03deploy.py失败。有关更多详细信息,请使用控制台或EB CLI检查/ var / log / eb-ac
tivity.log。


$ b INFO:命令执行已在所有实例上完成。摘要:[成功:0,失败:1]。



错误:执行实例id's-03e92fa3c58b6e010'失败。中止操作。



错误:无法部署应用程序。


$ b


2018-01 -19 04:26:53,878错误安装依赖关系时出错:命令'/ opt / python / run / venv / bin / pip
install -r /opt/python/ondeck/app/requirements.txt'返回非零退出状态2



回溯(最近一次通话最后一次):

文件/ opt / elasticbeanstalk / hooks / appdeploy / pre / 03deploy.py,第22行,主要内容是

install_dependencies()

文件​​/ opt / elasticbeanstalk / hooks / appdeploy / pre / 03deploy.py,第18行,在install_dependencies中。

check_call('%s install -r%s'%(os。 path.join(APP_VIRTUAL_ENV,'bin','pip'),requirements_file),
shell = True)





raise CalledPr oledError(retcode,cmd)

CalledProcessError:命令'/ opt / python / run / venv / bin / pip install -r / opt / python / ondeck / app / requiremen
ts.txt'返回非零退出状态2(Executor :: NonZeroExitStatus)

好像这个问题是由于AWS Elastic Beanstalk不支持 -e git + 安装?

解决方案

问题已解决。

这不是因为安装了PyDDE。 b
$ b

实际的原因是Scipy的安装需要大于40MB的内存,默认的EC2实例t1.micro没有足够的内存来安装它。它可以通过使用更大的EC2实例来解决。我最终与t2.medium一起。



另外,要安装Pandas,它需要gcc。我用这个修改了 .ebextensions \ [env_name] .config 文件:(我使用的是python 2.7,来自: elasticbeanstalk gcc和python-devel安装

  packages:
yum:
git:[]
gcc-c ++:[]
python27-devel:[]


I tried to deploy a Flask app on AWS Elastic Beanstalk using eb deploy but failed.

I have the requirements.txt under the app directory:

Flask==0.12.2
numpy==1.13.3
pandas==0.21.1
requests==2.18.4
scipy==1.0.0
Werkzeug==0.12.2
-e git+http://github.com/hensing/PyDDE#egg=PyDDE

And python.config file under .ebextensions directory:

packages:
  yum:
    git: []
    gcc-c++: []
    make: []

The error message is:

INFO: Environment update is starting.

INFO: Deploying new version to instance(s).

ERROR: Your requirements.txt is invalid. Snapshot your logs for details.

ERROR: [Instance: i-03e92fa3c58b6e010] Command failed on instance. Return code: 1 Output: (TRUNCATED)... )

File "/usr/lib64/python2.7/subprocess.py", line 541, in check_call

raise CalledProcessError(retcode, cmd)

CalledProcessError: Command '/opt/python/run/venv/bin/pip install -r /opt/python/ondeck/app/requirements .txt' returned non-zero exit status 2.

Hook /opt/elasticbeanstalk/hooks/appdeploy/pre/03deploy.py failed. For more detail, check /var/log/eb-ac tivity.log using console or EB CLI.

INFO: Command execution completed on all instances. Summary: [Successful: 0, Failed: 1].

ERROR: Unsuccessful command execution on instance id(s) 'i-03e92fa3c58b6e010'. Aborting the operation.

ERROR: Failed to deploy application.

And /var/log/eb-activity.log shows:

2018-01-19 04:26:53,878 ERROR Error installing dependencies: Command '/opt/python/run/venv/bin/pip install -r /opt/python/ondeck/app/requirements.txt' returned non-zero exit status 2

Traceback (most recent call last):

File "/opt/elasticbeanstalk/hooks/appdeploy/pre/03deploy.py", line 22, in main

install_dependencies()

File "/opt/elasticbeanstalk/hooks/appdeploy/pre/03deploy.py", line 18, in install_dependencies

check_call('%s install -r %s' % (os.path.join(APP_VIRTUAL_ENV, 'bin', 'pip'), requirements_file), shell=True)

File "/usr/lib64/python2.7/subprocess.py", line 541, in check_call

raise CalledProcessError(retcode, cmd)

CalledProcessError: Command '/opt/python/run/venv/bin/pip install -r /opt/python/ondeck/app/requiremen ts.txt' returned non-zero exit status 2 (Executor::NonZeroExitStatus)

It seems like this issue is because of the -e git+ installation is not supported by AWS Elastic Beanstalk?

解决方案

The problem has been resolved.

It was NOT because of installation of PyDDE.

The actual reason was that installation of Scipy requires > 40MB memory and the default EC2 instance, t1.micro, doesn't have enough memory to install it. It can be resolved by using a larger EC2 instance. I eventually go with t2.medium.

Also, to install Pandas, it requires gcc. I modified .ebextensions\[env_name].config file with this: (I'm using python 2.7, from: elasticbeanstalk gcc and python-devel installation)

packages:
  yum:
    git: []
    gcc-c++: []
    python27-devel: []

这篇关于AWS Elastic Beanstalk无法使用requirements.txt Git Pip安装Python包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆