Rose Perrone
Rose Perrone

Reputation: 63616

Target WSGI script not found or unable to stat

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:

enter image description here

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?

Upvotes: 10

Views: 7168

Answers (4)

Sachit Nagpal
Sachit Nagpal

Reputation: 486

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).

Upvotes: 5

Pooja Devarajan
Pooja Devarajan

Reputation: 1

Use application instead of app or any other variable you are using.

application = Flask(__name__)

Upvotes: 0

ken
ken

Reputation: 4077

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.

Upvotes: 0

zachguo
zachguo

Reputation: 6756

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.

Upvotes: 4

Related Questions