After successfully deploying a test app using the steps outlined here: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_Python_flask.html
I tried
As of awsebcli 3.0, you can actually edit your configuration settings to represent your WSGI
path via eb config
. The config
command will then pull (and open it in your default command line text editor, i.e nano) an editable config based on your current configuration settings. You'll then search for WSGI
and update it's path that way. After saving the file and exiting, your WSGI
path will be updated automatically.
WSGI configuration was painful for me. I did changed WSCI settings using eb config
command but it did not work. Below you can fix this in 5 easy steps.
1- Moved app.py
function to the root of the directory (where I runned eb init
command.
2- Also renamed app.py
as application.py
and in that initilized application as application = Flask(__name__)
not app = Flask(__name__)
3- eb deploy
did not worked after this (in the same project) I tried to fix config by using eb config
but it was too hairy to sort it out. Delete all .extensions, .gitignore etc from your project.
4- re initialize your project on EB with eb init
and follow the prompts. when deployment is done, eb open
would launch your webapp (hopefully!)
When I encountered this problem it was because I was using the GUI to upload a zip of my project files. Initially I was zipping the project level directory and uploading that zip to EB.
Then I switched to simply uploading a zip of the project files themselves-ie select all files and send those to a zip-and then the GUI upload utility was able to find my application.py file without a problem because the application.py file was not in a subfolder.
Add the following to .ebextensions/<env-name>.config
:
option_settings:
"aws:elasticbeanstalk:container:python":
WSGIPath: myApp/handlers/views.py
Update:
If you don't have .ebextensions directory, please create one for the project. You can find more information of what can be done regarding the container configuration in Customizing and Configuring AWS Elastic Beanstalk Environments guide.
Your WSGIPath refers to a file that does not exist.
This error appears because Beanstalk, by default, looks for application.py. Check at Beanstalk web UI, Configuration > Software Configuration
, WSGIPath
is mapped to application.py
Update the WSGIPath
as shown in the previous replies or rename to application.py
file.
Well, In my case I followed the entire process and conventions but was still getting 404. The problem was my virtual environment. I was ignoring all environment config related folders/files in my .gitignore but not in .ebignore. After creating .ebignore and ignoring all the folders/files which were not related to project code, fixed the issue.