Target WSGI script not found or unable to stat: /opt/python/current/app/application.py
I contain my app in a file called application.py
, and my application's configuration looks like this:
I also tried uploading the sample app that AWS provides, which only contains 'application.py`, and yet I still get this error.
What could be causing the error?
I had a similar issue. You should put your application.py
in root directory as your WSGIPath suggests, or change your WSGIPath in .elasticbeanstalk/optionsettings.yourappname-env
.
For me, it was this silly thing. In my mac, I compressed by right-clicking on the folder/repository and compressing it to zip. However, a zip like that extracts to open another folder within it which contains the application. As a result, EBS is unable to locate application.py.
The simple fix hence was to select all the individual files inside the folder to create the zip file for uploading (or using the EB CLI to upload).
For me, I had my app instance stored in a variable called app
, which wasn't recognised by Elastic Beanstalk. As soon as I changed the variable to application
, it started working.
# In application.py or manage.py, after initialising the app
application = app
should do the trick.
Use application
instead of app
or any other variable you are using.
application = Flask(__name__)