python - 将 django 应用程序部署到 aws beanstalk 时的 requirements.txt 无效

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

在我最近一次提交之前,我一直在将我的应用程序部署到 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

最佳答案

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

更新:

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

关于python - 将 django 应用程序部署到 aws beanstalk 时的 requirements.txt 无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18554666/

相关文章:

python - 通过将子列表的元素与Python中所有其他子列表中的元素进行比较来删除子列表

Python:如何使 ANSI 转义码也能在 Windows 中工作?

python - Numpy 数组到 base64 并返回到 Numpy 数组 - Python

amazon-web-services - AWSLambdaClient 调用给出异常 : com. amazonaws.SdkClientException:无法执行 HTTP 请求:目标服务器无法响应

c++ - glGenBuffers 不设置缓冲区

node.js - 在 AWS 上使用 Titan DynamoDB 并从 NodeJs 进行查询

python - 在python脚本中加载新安装的模块

python - 为什么 win32com 比 xlrd 慢那么多?

django-non rel 和 dbindexer 排序属性

html - 其中一个页面没有从基础继承 css