繁体   English   中英

AWS Elastic Beanstalk 错误地使用 Python 2 和 Python 3?

[英]AWS Elastic Beanstalk Using Python 2 and Python 3 in error?

我已按照 AWS 教程使用弹性 beanstalk 部署 django 应用程序( https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-django.ZFC35FZ8830D5FC67A25E36 当我使用 cli 进入 eb 环境创建阶段时,我遇到的错误表明 Python 2 以某种方式混合在一起,但情况并非如此。

我的环境已创建,但有错误,如下所述。

我考虑了以下几点。

-我重新查看了 django 教程并确保我遵循它。
-我已经研究了这个问题并查看了我的 eb 日志,但我无法确定对这个特定问题的见解。
-我已经确认 pywin 225 存在并且 aws 平台配置为 python 3.6(而不是日志建议的 2.7?)。

env创建日志尾部如下:

Creating application version archive "app-191001_120338".
Uploading ebdjango/app-191001_120338.zip to S3. This may take a while.
Upload Complete.
Environment details for: ebdjango-dev
  Application name: ebdjango
  Region: us-west-1
  Deployed Version: app-191001_120338
  Environment ID: e-ine5bnjxcv
  Platform: arn:aws:elasticbeanstalk:us-west-1::platform/Python 3.6 running on 64bit Amazon Linux/2.9.2
  Tier: WebServer-Standard-1.0
  CNAME: ebdjango-dev2.us-west-1.elasticbeanstalk.com
  Updated: 2019-10-01 19:03:41.226000+00:00
Printing Status:
2019-10-01 19:03:39    INFO    createEnvironment is starting.
2019-10-01 19:03:41    INFO    Using elasticbeanstalk-us-west-1-307455546112 as Amazon S3 storage bucket for environment data.
2019-10-01 19:04:03    INFO    Created target group named: arn:aws:elasticloadbalancing:us-west-1:307455546112:targetgroup/awseb-AWSEB-BNKO4RVK1UEY/9d7bd9879e64fe8e
2019-10-01 19:04:03    INFO    Created security group named: sg-08eeeeae2daaa824a
2019-10-01 19:04:18    INFO    Created security group named: awseb-e-ine5bnjxcv-stack-AWSEBSecurityGroup-1XHDD3SI17QRF
2019-10-01 19:04:19    INFO    Created Auto Scaling launch configuration named: awseb-e-ine5bnjxcv-stack-AWSEBAutoScalingLaunchConfiguration-1JT4JXF8UL7YO
2019-10-01 19:05:20    INFO    Created Auto Scaling group named: awseb-e-ine5bnjxcv-stack-AWSEBAutoScalingGroup-UOU7OOHIFLPM
2019-10-01 19:05:20    INFO    Waiting for EC2 instances to launch. This may take a few minutes.
2019-10-01 19:05:20    INFO    Created Auto Scaling group policy named: arn:aws:autoscaling:us-west-1:307455546112:scalingPolicy:374ae066-b319-4861-9043-1340fe3c1a1c:autoScalingGroupName/awseb-e-ine5bnjxcv-stack-AWSEBAutoScalingGroup-UOU7OOHIFLPM:policyName/awseb-e-ine5bnjxcv-stack-AWSEBAutoScalingScaleDownPolicy-40CWL7KRUGXQ
2019-10-01 19:05:20    INFO    Created Auto Scaling group policy named: arn:aws:autoscaling:us-west-1:307455546112:scalingPolicy:343a776e-ed77-4af1-a8f0-c0c59c9d3e0b:autoScalingGroupName/awseb-e-ine5bnjxcv-stack-AWSEBAutoScalingGroup-UOU7OOHIFLPM:policyName/awseb-e-ine5bnjxcv-stack-AWSEBAutoScalingScaleUpPolicy-8FST2RMX5LJH
2019-10-01 19:05:20    INFO    Created CloudWatch alarm named: awseb-e-ine5bnjxcv-stack-AWSEBCloudwatchAlarmHigh-1FB67ATMY3PVV
2019-10-01 19:05:20    INFO    Created CloudWatch alarm named: awseb-e-ine5bnjxcv-stack-AWSEBCloudwatchAlarmLow-163VGCKXY40IE
2019-10-01 19:06:10    INFO    Created load balancer named: arn:aws:elasticloadbalancing:us-west-1:307455546112:loadbalancer/app/awseb-AWSEB-15E7TQ3L7T3G4/297b8eee80310810
2019-10-01 19:06:10    INFO    Created Load Balancer listener named: arn:aws:elasticloadbalancing:us-west-1:307455546112:listener/app/awseb-AWSEB-15E7TQ3L7T3G4/297b8eee80310810/b6d5a64f37e36d16
2019-10-01 19:06:22    ERROR   Your requirements.txt is invalid. Snapshot your logs for details.
2019-10-01 19:06:25    ERROR   [Instance: i-0cd6718e8f5bee560] Command failed on instance. Return code: 1 Output: (TRUNCATED)...)
  File "/usr/lib64/python2.7/subprocess.py", line 190, 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 1.
Hook /opt/elasticbeanstalk/hooks/appdeploy/pre/03deploy.py failed. For more detail, check /var/log/eb-activity.log using console or EB CLI.
2019-10-01 19:06:26    INFO    Command execution completed on all instances. Summary: [Successful: 0, Failed: 1].
2019-10-01 19:07:28    ERROR   Create environment operation is complete, but with errors. For more information, see troubleshooting documentation.

对 /usr/lib64/python2.7/subprocess.py 的引用让我失望,因为我使用的是 Python 3.6.1。

当我查看 'requirements.txt 无效问题的日志时,错误来自。

Collecting pywin32==225 (from -r /opt/python/ondeck/app/requirements.txt (line 16))
    Could not find a version that satisfies the requirement pywin32==225 (from -r /opt/python/ondeck/app/requirements.txt (line 16)) (from versions: )
  No matching distribution found for pywin32==225 (from -r /opt/python/ondeck/app/requirements.txt (line 16))

pywin32==225 确实存在。 我还尝试手动将 requirements.txt 版本更改为 223(单独尝试),但没有成功。 我这样做只是为了尝试一些不是 pywin32 最新版本的东西,看看我是否会得到不同的结果。

错误日志继续引用 python 2.7。

You are using pip version 9.0.1, however version 19.2.3 is available.
  You should consider upgrading via the 'pip install --upgrade pip' command.
  2019-10-01 19:06:22,598 ERROR    Error installing dependencies: Command '/opt/python/run/venv/bin/pip install -r /opt/python/ondeck/app/requirements.txt' returned non-zero exit status 1
  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 190, 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 1 (ElasticBeanstalk::ExternalInvocationError)
caused by: Collecting awsebcli==3.15.3 (from -r /opt/python/ondeck/app/requirements.txt (line 1)) 

我不希望有任何 python 2 引用,因为这都是为 python 3.6 配置的。 事实上,当我登录 AWS 控制台时,我可以确认平台是在 64 位 Amazon Linux/2.9.2 上运行的 Python 3.6。

我希望使用 eb CLI 创建此应用程序/环境不会有任何问题,因为我完全遵循 AWS django 教程。

收到这些错误消息后,我为该项目启动了 git 存储库,以便其他人可以查看我的需求和配置文件。 https://github.com/rdemint/ebdjango

提前致谢

pywin32仅在windows上可用。 错误日志显示 requirements.txt 没有成功安装软件包,并且在某些步骤上失败,因此返回非零状态。

You can either install use python with wine on your Amazon Linux (you can use container commands to manage the installation packages) or create an EC2 Windows instance, Bake the AMI with required packages, then in the Elasticbeanstalk environment select your custom AMI. 最后,您可以在 Elasticbeanstalk 上部署您的应用程序。

我刚刚卸载了pywin32和pypiwin32,这些命令一一使用,

pip uninstall pywin32
pip uninstall pypiwin32
pip freeze > requirements.txt

现在提交后将代码推送到 Github。 这为我解决了这个问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM