No module named 'application' Error while deploying simple web app to Elastic Beanstalk No module named 'application' Error while deploying simple web app to Elastic Beanstalk flask flask

No module named 'application' Error while deploying simple web app to Elastic Beanstalk


A possible reason is the use of Amazon Linux 2 environment, instead of Amazon Linux 1.

The list of python environments and their linux distributions is here.

From the link you provided:

In this tutorial we use Python 3.6 and the corresponding Elastic Beanstalk platform version.

The Python 3.6 is supported in Amazon Linux 1 environment, while you are using Python 3.7 which is for Amazon Linux 2 environment.

There are many differences between AL1 and AL2, which make them incompatible.


I had the same issue as you. Downgrading to AL1 does solve this but brings more issues.

I found that you can make your app compatible by adding the following line to the end of the file.

app = application

Alternatifly you can do this when you define the flask instance:

application = app = Flask(__name__)do not forget to import both into application.py if needed.

This works because aws needs the Flask instance to be called application but gunicorn needs the Flask instance to be called app so this way you make them both happy.

Everyone in the world calls there Flask instances app execpt for aws apperently.