3

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:

enter image description here

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
lucasrf27
  • 350
  • 2
  • 16
  • Are you using Amazon Linux 1 or Amazon Linux 2? Unfortunately, the config file will need to be different depending on which version you are using. – Daniel Sep 24 '21 at 18:47
  • Amazon Linux 2, am i missing some file? – lucasrf27 Sep 24 '21 at 19:03
  • Can you show the contents of `eb logs`? – Daniel Sep 24 '21 at 20:13
  • Having you committed all these files ? If you have initialised git for your project, it deploys the latest commit from current branch - https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb3-cli-git.html – gowthz Sep 28 '21 at 06:53
  • i've tried before and tried yesterday either, still same problem. – lucasrf27 Sep 29 '21 at 14:13
  • did you even find a solution to this? – alphazwest Feb 14 '22 at 13:35
  • i didn't, so stopped trying with Elastic Beanstalk and deployed on a EC2 @alphazwest – lucasrf27 Feb 22 '22 at 19:35
  • 1
    @lucasrf27 FWIW -- I finally got mine to disappear and work as expected after dealing with some other upstream issues. It was having trouble in the build phase -- just not in an error-generating capacity. It was evident b/c even with the correct .config settings -- the `wsgi` path wasn't being updated in the online ELB console view and still reflected just `application` vs. `project.wsgi.py:application`. For me, it was an SQLite3 issue that was resolved by switching to `postgres` which made sense anyway. – alphazwest Feb 22 '22 at 19:45
  • @alphazwest appreciate so much the feedback, definitely will try with postgres soon – lucasrf27 Feb 22 '22 at 19:47

3 Answers3

1

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

jillserge
  • 11
  • 2
0
  1. You have a typo ".ebextentions" instead of ".ebextensions"

  2. 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"

Andi Schroff
  • 1,156
  • 1
  • 12
  • 18
0
  1. You have a typo ".ebextentions" instead of ".ebextensions"

2.In the configuration module go to software

3.Then in the WSGIPath add c2exchange.wsgi:application instead of application

Last Saint
  • 31
  • 2
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Feb 01 '23 at 10:25