【问题标题】:Elastic Beanstalk: /bin/sh: /opt/python/run/venv/bin/activate: No such file or directoryElastic Beanstalk: /bin/sh: /opt/python/run/venv/bin/activate: 没有这样的文件或目录
【发布时间】:2020-10-09 13:42:43
【问题描述】:

尝试部署一个使用https://medium.com/@elspanishgeek/how-to-deploy-django-channels-2-x-on-aws-elastic-beanstalk-8621771d4ff0之后的频道的django应用程序

这些是我的配置文件:

01_env.config

option_settings:  
  aws:elasticbeanstalk:container:python:     
    WSGIPath: "dashboard/wsgi.py"
  aws:elasticbeanstalk:application:environment:
    DJANGO_SETTINGS_MODULE: "dashboard.settings"
    PYTHONPATH: /opt/python/current/app/dashboard:$PYTHONPATH

  aws:elbv2:listener:80:
    DefaultProcess: http
    ListenerEnabled: 'true'
    Protocol: HTTP
    Rules: ws
  aws:elbv2:listenerrule:ws:
    PathPatterns: /websockets/*
    Process: websocket
    Priority: 1
  aws:elasticbeanstalk:environment:process:http:
    Port: '80'
    Protocol: HTTP
  aws:elasticbeanstalk:environment:process:websocket:
    Port: '5000'
    Protocol: HTTP

02_setup.config

container_commands:
  00_pip_upgrade:
    command: "source /opt/python/run/venv/bin/activate && pip install --upgrade pip"
    ignoreErrors: false
  01_migrate:
    command: "django-admin.py migrate"
    leader_only: true
  02_collectstatic:
    command: "django-admin.py collectstatic --noinput"
  03_wsgipass:
    command: 'echo "WSGIPassAuthorization On" >> ../wsgi.conf'

当我运行 eb create django-env 时,它会失败并显示

Command failed on instance. An unexpected error has occurred [ErrorCode: 0000000001].

在日志中,我发现原因是:

2020-06-17 16:36:41,880 P4189 [INFO] Command 00_pip_upgrade
2020-06-17 16:36:41,883 P4189 [INFO] -----------------------Command Output-----------------------
2020-06-17 16:36:41,883 P4189 [INFO]    /bin/sh: /opt/python/run/venv/bin/activate: No such file or directory

因此,即使我按照指南进行操作,该目录似乎也不存在。我也无法通过 SSH 进入 EC2 实例来检查这一点。 Amazon Linux 2 中的 python venv 目录有变化吗?

【问题讨论】:

  • 您找到 AL2 解决方案了吗?

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


【解决方案1】:

这不起作用,因为您使用的是Amazon Linux 2,而您关注的教程使用的是Amazon Linux 1

要在创建 Python 环境时使用Amazon Linux 1,请选择:

Python 3.6 running on 64bit Amazon Linux

请注意,AL2 和 AL1 之间存在巨大差异,大多数涉及 AL1 的教程在 AL2 中都无法使用。

【讨论】:

    【解决方案2】:

    如果您想尝试使用 Amazon Linux 2,可以关注Aws documentation on deploying a django project

    【讨论】:

    • 这不是回答问题,请不要只是复制文档来回复。
    猜你喜欢
    • 2020-10-10
    • 2019-12-10
    • 1970-01-01
    • 1970-01-01
    • 2016-11-16
    • 1970-01-01
    • 2019-03-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多