How do I fix this Elastic Beanstalk error when deploying a Flask app: Python 3.7.0 was not found on your system

試著忘記壹切 提交于 2021-01-28 19:42:30

问题


I am trying to deploy my Flask app using the EB CLI following this official AWS tutorial. I receive the error 'Create environment operation is complete, but with errors'. Observing the environment logs, the server seems to be lacking the correct Python version.

Below are the EB environment details, my PipFile, the EB CLI output and the error in the deploy logs.

How can I fix this problem?

Environment details:

 Application name: server_eb
  Region: eu-west-2
  Deployed Version: XXX
  Environment ID: XXX
  Platform: arn:aws:elasticbeanstalk:eu-west-2::platform/Python 3.7 running on 64bit Amazon Linux 2/3.0.1
  Tier: WebServer-Standard-1.0
  CNAME: UNKNOWN
  Updated: 2020-06-02 16:53:10.321000+00:00

PipFile:

[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]

[packages]
flask = "~=1.1.1"
python-dotenv = "~=0.13.0"
psycopg2 = "~=2.8.5"
flask-sqlalchemy = "~=2.4.1"
flask-migrate = "~=2.5.3"
flask-dance = {extras = ["sqla"],version = "~=3.0.0"}
flask-login = "~=0.4.1"
blinker = "~=1.4"
flask-session = "==0.3.1"
redis = "==3.4.1"

[scripts]
migrate="flask db upgrade"
start="flask run --cert=cert.pem --key=key.pem"

[requires]
python_version = "3.7.0"

CLI output:

2020-06-02 16:54:55    ERROR   [Instance: XXX] Command failed on instance. An unexpected error has occurred [ErrorCode: 0000000001].
2020-06-02 16:54:55    INFO    Command execution completed on all instances. Summary: [Successful: 0, Failed: 1].
2020-06-02 16:55:57    ERROR   Create environment operation is complete, but with errors. For more information, see troubleshooting documentation.

ERROR: ServiceError - Create environment operation is complete, but with errors. For more information, see troubleshooting documentation.

Logs:

2020/06/02 16:54:55.030996 [ERROR] An error occurred during execution of command [app-deploy] - [SetUpPythonEnvironment]. Stop running the command. Error: fail to install Gunicorn with error Command /bin/sh -c python3 -m pipenv install gunicorn --skip-lock failed with error exit status 1. Stderr:Warning: the environment variable LANG is not set!
We recommend setting this in ~/.profile (or equivalent) for proper expected behavior.
Warning: Python 3.7.0 was not found on your system…
You can specify specific versions of Python with:
  $ pipenv --python path/to/python

回答1:


Based on the comments, the issue was that the EB uses Python 3.7.6, while the OP's dependencies required version 3.7.0.

The solution was to change the dependency to Python 3.7.6.

The current python version running on EB can be found here:

64bit Amazon Linux 2 v3.0.1 running Python 3.7 - Python 3.7.6



来源:https://stackoverflow.com/questions/62170836/how-do-i-fix-this-elastic-beanstalk-error-when-deploying-a-flask-app-python-3-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!