I’ve been trying to deploy a Django application at ElasticBeanstalk from AWS.
I have followed this tutorial probably 6 or 7 times.
tried to deploy from Linux and from windows machine in either way I end up getting:
ModuleNotFoundError: No module named 'application'
or web: Failed to find attribute 'application' in 'application'.
the other files are blank because I’ve tried with a project of mine and now I’m trying with a blank one.
django.config
option_settings:
aws:elasticbeanstalk:container:python:
WSGIPath: c2exchange.wsgi:application
wsgi.py:
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'c2exchange.settings')
application = get_wsgi_application()
those are my files:
Logs:
----------------------------------------
/var/log/web.stdout.log
----------------------------------------
Sep 24 22:23:48 ip-172-31-33-134 web: File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
Sep 24 22:23:48 ip-172-31-33-134 web: File "<frozen importlib._bootstrap>", line 991, in _find_and_load
Sep 24 22:23:48 ip-172-31-33-134 web: File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
Sep 24 22:23:48 ip-172-31-33-134 web: ModuleNotFoundError: No module named 'application'
Sep 24 22:23:48 ip-172-31-33-134 web: [2021-09-24 22:23:48 +0000] [1250] [INFO] Worker exiting (pid: 1250)
Sep 24 22:23:48 ip-172-31-33-134 web: [2021-09-24 22:23:48 +0000] [1244] [INFO] Shutting down: Master
Sep 24 22:23:48 ip-172-31-33-134 web: [2021-09-24 22:23:48 +0000] [1244] [INFO] Reason: Worker failed to boot.
Sep 24 22:23:48 ip-172-31-33-134 web: [2021-09-24 22:23:48 +0000] [1258] [INFO] Starting gunicorn 20.1.0
Sep 24 22:23:48 ip-172-31-33-134 web: [2021-09-24 22:23:48 +0000] [1258] [INFO] Using worker: gthread
Sep 24 22:23:48 ip-172-31-33-134 web: [2021-09-24 22:23:48 +0000] [1264] [INFO] Booting worker with pid: 1264
Sep 24 22:23:48 ip-172-31-33-134 web: [2021-09-24 22:23:48 +0000] [1264] [ERROR] Exception in worker process
Sep 24 22:23:48 ip-172-31-33-134 web: Traceback (most recent call last):
Sep 24 22:23:48 ip-172-31-33-134 web: worker.init_process()
Sep 24 22:23:48 ip-172-31-33-134 web: super().init_process()
Sep 24 22:23:48 ip-172-31-33-134 web: self.load_wsgi()
Sep 24 22:23:48 ip-172-31-33-134 web: self.wsgi = self.app.wsgi()
Sep 24 22:23:48 ip-172-31-33-134 web: self.callable = self.load()
Sep 24 22:23:48 ip-172-31-33-134 web: return self.load_wsgiapp()
Sep 24 22:23:48 ip-172-31-33-134 web: return util.import_app(self.app_uri)
Sep 24 22:23:48 ip-172-31-33-134 web: mod = importlib.import_module(module)
Sep 24 22:23:48 ip-172-31-33-134 web: File "/usr/lib64/python3.8/importlib/__init__.py", line 127, in import_module
Sep 24 22:23:48 ip-172-31-33-134 web: return _bootstrap._gcd_import(name[level:], package, level)
Sep 24 22:23:48 ip-172-31-33-134 web: File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
Sep 24 22:23:48 ip-172-31-33-134 web: File "<frozen importlib._bootstrap>", line 991, in _find_and_load
Sep 24 22:23:48 ip-172-31-33-134 web: File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
Sep 24 22:23:48 ip-172-31-33-134 web: ModuleNotFoundError: No module named 'application'
Sep 24 22:23:48 ip-172-31-33-134 web: [2021-09-24 22:23:48 +0000] [1264] [INFO] Worker exiting (pid: 1264)
Sep 24 22:23:48 ip-172-31-33-134 web: [2021-09-24 22:23:48 +0000] [1258] [INFO] Shutting down: Master
Sep 24 22:23:48 ip-172-31-33-134 web: [2021-09-24 22:23:48 +0000] [1258] [INFO] Reason: Worker failed to boot.
Sep 24 22:23:49 ip-172-31-33-134 web: [2021-09-24 22:23:49 +0000] [1272] [INFO] Starting gunicorn 20.1.0
Sep 24 22:23:49 ip-172-31-33-134 web: [2021-09-24 22:23:49 +0000] [1272] [INFO] Using worker: gthread
Sep 24 22:23:49 ip-172-31-33-134 web: [2021-09-24 22:23:49 +0000] [1278] [INFO] Booting worker with pid: 1278
Sep 24 22:23:49 ip-172-31-33-134 web: [2021-09-24 22:23:49 +0000] [1278] [ERROR] Exception in worker process
Sep 24 22:23:49 ip-172-31-33-134 web: Traceback (most recent call last):
Sep 24 22:23:49 ip-172-31-33-134 web: worker.init_process()
Sep 24 22:23:49 ip-172-31-33-134 web: super().init_process()
Sep 24 22:23:49 ip-172-31-33-134 web: self.load_wsgi()
Sep 24 22:23:49 ip-172-31-33-134 web: self.wsgi = self.app.wsgi()
Sep 24 22:23:49 ip-172-31-33-134 web: self.callable = self.load()
Sep 24 22:23:49 ip-172-31-33-134 web: return self.load_wsgiapp()
Sep 24 22:23:49 ip-172-31-33-134 web: return util.import_app(self.app_uri)
Sep 24 22:23:49 ip-172-31-33-134 web: mod = importlib.import_module(module)
Sep 24 22:23:49 ip-172-31-33-134 web: File "/usr/lib64/python3.8/importlib/__init__.py", line 127, in import_module
Sep 24 22:23:49 ip-172-31-33-134 web: return _bootstrap._gcd_import(name[level:], package, level)
Sep 24 22:23:49 ip-172-31-33-134 web: File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
Sep 24 22:23:49 ip-172-31-33-134 web: File "<frozen importlib._bootstrap>", line 991, in _find_and_load
Sep 24 22:23:49 ip-172-31-33-134 web: File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
Sep 24 22:23:49 ip-172-31-33-134 web: ModuleNotFoundError: No module named 'application'
Sep 24 22:23:49 ip-172-31-33-134 web: [2021-09-24 22:23:49 +0000] [1278] [INFO] Worker exiting (pid: 1278)
Sep 24 22:23:49 ip-172-31-33-134 web: [2021-09-24 22:23:49 +0000] [1272] [INFO] Shutting down: Master
Sep 24 22:23:49 ip-172-31-33-134 web: [2021-09-24 22:23:49 +0000] [1272] [INFO] Reason: Worker failed to boot.
Sep 24 22:23:49 ip-172-31-33-134 web: [2021-09-24 22:23:49 +0000] [1286] [INFO] Starting gunicorn 20.1.0
Sep 24 22:23:49 ip-172-31-33-134 web: [2021-09-24 22:23:49 +0000] [1286] [INFO] Using worker: gthread
Sep 24 22:23:49 ip-172-31-33-134 web: [2021-09-24 22:23:49 +0000] [1292] [INFO] Booting worker with pid: 1292
Sep 24 22:23:49 ip-172-31-33-134 web: [2021-09-24 22:23:49 +0000] [1292] [ERROR] Exception in worker process
Sep 24 22:23:49 ip-172-31-33-134 web: Traceback (most recent call last):
Sep 24 22:23:49 ip-172-31-33-134 web: worker.init_process()
Sep 24 22:23:49 ip-172-31-33-134 web: super().init_process()
Sep 24 22:23:49 ip-172-31-33-134 web: self.load_wsgi()
Sep 24 22:23:49 ip-172-31-33-134 web: self.wsgi = self.app.wsgi()
Sep 24 22:23:49 ip-172-31-33-134 web: self.callable = self.load()
Sep 24 22:23:49 ip-172-31-33-134 web: return self.load_wsgiapp()
Sep 24 22:23:49 ip-172-31-33-134 web: return util.import_app(self.app_uri)
Sep 24 22:23:49 ip-172-31-33-134 web: mod = importlib.import_module(module)
Sep 24 22:23:49 ip-172-31-33-134 web: File "/usr/lib64/python3.8/importlib/__init__.py", line 127, in import_module
Sep 24 22:23:49 ip-172-31-33-134 web: return _bootstrap._gcd_import(name[level:], package, level)
Sep 24 22:23:49 ip-172-31-33-134 web: File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
Sep 24 22:23:49 ip-172-31-33-134 web: File "<frozen importlib._bootstrap>", line 991, in _find_and_load
Sep 24 22:23:49 ip-172-31-33-134 web: File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
Sep 24 22:23:49 ip-172-31-33-134 web: ModuleNotFoundError: No module named 'application'
Sep 24 22:23:49 ip-172-31-33-134 web: [2021-09-24 22:23:49 +0000] [1292] [INFO] Worker exiting (pid: 1292)
Sep 24 22:23:49 ip-172-31-33-134 web: [2021-09-24 22:23:49 +0000] [1286] [INFO] Shutting down: Master
Sep 24 22:23:49 ip-172-31-33-134 web: [2021-09-24 22:23:49 +0000] [1286] [INFO] Reason: Worker failed to boot.
----------------------------------------
/var/log/nginx/access.log
----------------------------------------
172.31.37.198 - - [24/Sep/2021:18:12:26 +0000] "GET /favicon.ico HTTP/1.1" 502 559 "http://c2deving.eba-zv3cph3u.sa-east-1.elasticbeanstalk.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36" "177.142.87.161"
172.31.8.207 - - [24/Sep/2021:18:15:30 +0000] "GET /favicon.ico HTTP/1.1" 502 559 "http://c2deving.eba-zv3cph3u.sa-east-1.elasticbeanstalk.com/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36" "177.142.87.161"
172.31.37.198 - - [24/Sep/2021:19:08:15 +0000] "GET /favicon.ico HTTP/1.1" 502 559 "htt
3
Answers
Try
if you are using a mac, make sure you are zipping the files,
not at the lop level.
https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/applications-sourcebundle.html
You have a typo ".ebextentions" instead of ".ebextensions"
Since you have a .gitignore I expect that you use git for your project. I had the same problem once, because I did not commit all changes before "eb deploy"
2.In the configuration module go to software
3.Then in the WSGIPath add c2exchange.wsgi:application instead of application