I'm attempting to deploy my first application to EB and am following along with this turorial: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-django.html
Unfortunately, I'm still getting a 502 error when deploying the final app. I'm confused because I've followed the directions to the tee.
I'm getting the following error
ImportError: Failed to find application, did you mean 'ebdjango/wsgi:application'?
I'm not sure what this means. Per the instructions, I edited the django.config file to include this text:
option_settings:
aws:elasticbeanstalk:container:python:
WSGIPath: ebdjango/wsgi.py
This appears to match my file structure:
- ebdjango
-.ebextensions
- django.config
- .elasticbeanstalk
- ebdjango
_ __init__.py
- settings.py
- urls.py
- wsgi.py
- manage.py
- requirements.txt
So the config file is set up correctly, right?
I'm running Python 3.7 and Django 2.2.
I know that EB searches for application.py, and I thought the config file is supposed to point the server towards my custom app? What am I missing here?
EDIT: I'm also getting this error:
ModuleNotFoundError: No module named 'ebdjango/wsgi'
Is something off about my file structure?
EDIT 2: I forgot to include the init.py file in my post, see Ben's comment.
I had the same issue. It is because of the Amazon Linux 2 machine image. Its configuration files are incompatible with those of the old version. Please see: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.migration-al.html. I ended up using the old version because the documentation says:
If you're using an Amazon Linux 2 platform version that is in beta for your evaluation, do not go to production. Wait until we release a supported platform version.
You can create an Elastic Beanstalk environment using the Amazon Linux machine image (old version) using the command line tool. Here are the commands (replace <...>
with your data):
eb init -p python-3.6 <ApplicationName> --region <Region>
eb create <EnvironmentName> --elb-type application --platform "64bit Amazon Linux 2018.03 v2.9.10 running Python 3.6"
Update 2020-06-02
As I mentioned before, the issue is caused by Amazon Linux 2 platform because it uses Gunicorn, which has a WSGI syntax that is different than the previous version. The WSGIPath
must be ebdjango.wsgi:application
. Please see https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-container.html#python-namespaces.
In your django.config change:
option_settings:
aws:elasticbeanstalk:container:python:
WSGIPath: ebdjango.wsgi
And in your
import os
from django.core.wsgi import get_wsgi_application
os.environ["DJANGO_SETTINGS_MODULE"] = "ebdjango.settings"
application = get_wsgi_application()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With