【问题标题】:Invalid requirements.txt on deploying django app to aws beanstalk将 django 应用程序部署到 aws beanstalk 时的 requirements.txt 无效
【发布时间】:2013-09-04 11:13:24
【问题描述】:

在我最近一次提交之前,我一直在将我的应用程序部署到 beanstalk 环境中,没有任何问题。

现在我明白了

Time    Type    Details
2013-09-01 10:19:12 UTC+0800    ERROR   Failed to deploy application.
2013-09-01 10:19:11 UTC+0800    ERROR   Responses from [i-50f40d06] were received, but the commands failed.
2013-09-01 10:19:11 UTC+0800    ERROR   Your requirements.txt is invalid. Snapshot your logs for details.
2013-09-01 10:19:11 UTC+0800    ERROR   [Instance: i-50f40d06 Module: AWSEBAutoScalingGroup ConfigSet: Hook-PreAppDeploy] Failed on instance with return code: 1 Output: Error occurred during build: Command hooks failed .

快照日志是这样说的:

2013-09-01 02:19:08,852 [INFO] (9941 MainThread) [directoryHooksExecutor.py-29] [root directoryHooksExecutor info] Output from script: New python executable in /opt/python/run/venv/bin/python2.6
Not overwriting existing python script /opt/python/run/venv/bin/python (you must use /opt/python/run/venv/bin/python2.6)
Installing distribute..................................................................................................................................................................................................done.
Installing pip................done.
2013-09-01 02:19:08,564 ERROR    Error installing dependencies: Command '/opt/python/run/venv/bin/pip install --use-mirrors -r /opt/python/ondeck/app/requirements.txt' returned non-zero exit status -9
Traceback (most recent call last):
  File "/opt/elasticbeanstalk/hooks/appdeploy/pre/03deploy.py", line 31, in main
    install_dependencies()
  File "/opt/elasticbeanstalk/hooks/appdeploy/pre/03deploy.py", line 25, in install_dependencies
    shell=True)
  File "/usr/lib/python2.6/subprocess.py", line 502, in check_call
    raise CalledProcessError(retcode, cmd)
CalledProcessError: Command '/opt/python/run/venv/bin/pip install --use-mirrors -r /opt/python/ondeck/app/requirements.txt' returned non-zero exit status -9

2013-09-01 02:19:08,853 [ERROR] (9941 MainThread) [directoryHooksExecutor.py-34] [root directoryHooksExecutor error] Script failed with returncode 1
2

我的 requirements.txt 和以前一样。我也尝试删除 requirements.txt 中的所有内容,但我再次遇到同样的错误,这让我认为问题出在 requirements.txt 运行之前。

我不知道部署的顺序。无论如何,这是我的配置文件:

packages:
  yum:
    libjpeg-devel: '6b'
    zlib-devel: []
    freetype-devel: []


container_commands:
  01_install_mysqldb:
    command: "pip install distribute==0.6.28; pip install mysql-python;"
  02_syncdb:
    command: "python manage.py syncdb --noinput"
    leader_only: true
  03_createadmin:
    command: "python scripts/createadmin.py"
    leader_only: true
  04_collectstatic:
    command: "python manage.py collectstatic --noinput"
  05_migrate_wizards:
    command: "python manage.py migrate wizards --noinput"
    leader_only: true
  06_migrate_facebook:
    command: "python manage.py migrate facebook --noinput"
    leader_only: true
  07_migrate_socialaccount:
    command: "python manage.py migrate socialaccount 0011 --noinput"
    leader_only: true
  08_migrate_missions:
    command: "python manage.py migrate missions --noinput"
    leader_only: true
  09_migrate_mailchimp:
    command: "python manage.py migrate mailchimp --noinput"
    leader_only: true
  10_migrate_actstream:
    command: "python manage.py migrate actstream --noinput"
    leader_only: true

option_settings:
  - namespace: aws:elasticbeanstalk:container:python
    option_name: WSGIPath
    value: ideatory/wsgi.py
  - namespace: aws:elasticbeanstalk:container:python:staticfiles
    option_name: /static/
    value: static/
  - option_name: DJANGO_SETTINGS_MODULE
    value: ideatory.settings

【问题讨论】:

  • -@vaisaghvt 你的问题解决了吗?
  • 正如下面的@jvannistelrooy 所说,最终对我有用的唯一一件事就是重建环境。
  • 如何查看快照日志?

标签: python django amazon-web-services amazon-elastic-beanstalk


【解决方案1】:

我遇到了完全相同的问题。唯一对我有用的是(自动)重建我的整个环境。您可以在 AWS 控制台中执行此操作。转到您的环境并单击操作 > 重建环境。这将需要一些时间,之后它会自动重新启动您的应用而不会出现此错误。

更新:

问题不时出现。我发现当 pip 编译 psycopg 时出现问题,这是 postgreSQL 支持所必需的。还没有找到真正的解决方案。

【讨论】:

  • 你找到 psycopg 的解决方案了吗?我面临同样的问题,并试图弄清楚。谢谢!
  • @user2608802 不,很遗憾我停止使用 Elastic Beanstalk 并更改了我的 AWS 设置。
  • 这个来自realpython.com的博客好像有解决办法:realpython.com/blog/python/…
  • 有没有人找到解决这个问题的方法。我上次提交后遇到了完全相同的错误。有趣的是,我没有更改任何代码行。唯一不同的是,由于换了电脑,我不得不在我的机器上重新安装 EB。
  • 为了构建 psycopg,您的环境需要 postgresql93-devel(或 94,取决于您的平台版本)
【解决方案2】:

我可以通过将postgresql93-develpostgresql93 添加到我的.ebextensions 来完成这项工作

Customizing the Software on EC2 Instances Running Linux

中所述

这适用于64bit Amazon Linux 2014.09 v1.0.9 running Python 2.7

.ebextensions/01_pre_deps.config:

packages:
  yum:
    gcc-c++: []
    make: []
    openssl-devel: []
    git: []
    python-devel: []
    python27-devel: []
    ruby-devel: []
    postgresql93: []
    postgresql93-devel: []
    # nginx: []
  rubygems:
    bundler: '1.7.3'
    compass-core: '1.1.0.alpha.3'
    neat-compass: '1.6.0'

【讨论】:

  • 我实际上使用的是 MySQL 数据库,所以我认为这个解决方案不适用。
  • 这对我有用,我必须在我的配置文件中添加的行是 packages/yum/ 标题下的 postgresql93 和 postgresql93-devel 行。我正在运行这个 aws beanstalk
  • 我在本地 ubuntu 机器上运行了 postgresql 10.7。我应该将 postgresql10:[ ] 添加到 .ebextensions 文件吗?
  • @Aseem 这对我来说很有意义。
【解决方案3】:

您确定安装了mysql-devel 软件包吗?它似乎没有包含在您的配置文件的 yum 部分中。

【讨论】:

  • 我有同样的问题,但是我安装了mysql-devel。
  • 是的,它已安装。正如我所提到的,在这次提交之前它运行良好。不知道出了什么问题,但重建环境是唯一有效的方法。
【解决方案4】:

虽然与 OP 描述的场景不同,但它可能对某人有用:

在尝试将最小测试应用程序部署到 Elastic Beanstalk 上新创建的 t1.micro 实例时,我们收到了相同的 ERROR Your requirements.txt is invalid. Snapshot your logs for details. 消息。

测试应用程序包含基本的 AWS Python 示例应用程序 (from here),我们从生产环境中添加了 .ebextensions/software.configrequirements.txt。唯一的目的是在部署中测试这两个文件。

仔细检查日志发现MemoryErrorpip install 期间。升级到t2.small 实例后,部署成功,没有问题。

【讨论】:

    【解决方案5】:

    无论出于何种原因,AWS 都不会按照 yolk 的建议安装来自我的 .extensions/01_packets.configpostgresql-devel 数据包。所以我不得不添加

    container_commands:
      01_addPostgreSQLPacket:
        command: 'yum install postgresql95-devel'
        leader_only: true
    

    致我的02_django.config。之后它工作得很好。

    【讨论】:

      猜你喜欢
      • 2016-07-01
      • 1970-01-01
      • 2015-06-28
      • 1970-01-01
      • 2013-04-03
      • 2015-01-25
      • 2014-05-03
      • 2021-02-11
      • 2018-12-07
      相关资源
      最近更新 更多