2

I'm trying to deploy my Flask web app using AWS EB (Amazon Web Services Elastic Beanstalk). Unfortunately, I'm running into the following error:

Your WSGIPath refers to a file that does not exist.

I've looked at the answers here and here; following the first suggestion didn't change anything (still received the same error). For reference, this fix involved creating an .ebextensions/ethanWebsite-env.config file with the contents below, where ethanWebsite-env is the name of my environment.

option_settings:
  "aws:elasticbeanstalk:container:python":
    WSGIPath: application.py

The second link suggests using the EB CLI command eb config to modify the WSGIPath environment variable. I've already done this using the AWS web GUI (the Software Configuration pane of the Configuration tab for my environment); it was already set to application.py but I reset it to no avail. The error I get from attempting eb config is perhaps more illuminating.

sh: -c: line 0: unexpected EOF while looking for matching `''
sh: -c: line 1: syntax error: unexpected end of file

Similarly, if I specify the environment to configure with eb config ethanWebsite-env, I receive the same error.

Here is the structure of my app.

ethan_website/
    application.py
    connect4.py
    isPrime.py
    requirements.txt
    .ebextensions/
        ethanWebsite-env.config
    .elasticbeanstalk/
        config.yml
    static/
        (various .css and .js files)
    templates/
        (various .html files)

I omitted a flask/ folder at the main project level, with lots of subfolders, which appears to configure the python environment and does not seem relevant.

If anyone has any insight into what could be the issue, please let me know. My error with eb config suggests to me that there is an issue with a config file, but I'm not sure where to start/look beyond the one I've already added. Thanks!

Community
  • 1
  • 1
Ethan S
  • 31
  • 1
  • 4
  • I was able to fix this by doing a fresh deployment of my application in a new environment, strictly from the EB CLI as outlined [here](http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-flask.html). Still wish I had some insight as to why my previous method broke, though. I also still get the same error when I use `eb config`. – Ethan S Aug 03 '16 at 17:54
  • From where do you get this error: Your WSGIPath refers to a file that does not exist.? – Brainless Nov 24 '20 at 22:46

2 Answers2

4

I don't know if this solves your problem or not, but I had the same exact issue and I came across this article. It explains that the default application object name in the flask app for Elastic Beanstalk should be called application instead of app.

So for example, in your main application, you should make the following change (if you haven't already):

app = Flask(__name__)

to

application = Flask(__name__)
oxtay
  • 3,990
  • 6
  • 30
  • 43
0

After spending several weeks on this issue. I figured out there can be 2 solutions for the above problem:

  1. Default object name in the flask server file should be application run function will look like application.run(host='0.0.0.0'), also the file name should be application.py or you can change the WSGI PATH in eb config to the name of your file. I'll prefer to have application.py.

  2. Even after trying out the first solution if it does not work then change the WSGI PATH to folder_name/application.py. I hope it helps.