ModuleNotFoundError: Нет модуля с именем «приложение» [Развертывание Django в AWS]

#python #python-3.x #django #amazon-web-services #amazon-elastic-beanstalk

Вопрос:

Я пытался развернуть приложение Django в ElasticBeanstalk из AWS.

Я следовал этому уроку, вероятно, 6 или 7 раз.

попытался развернуть с Linux и с машины Windows в любом случае, в итоге я получаю: ModuleNotFoundError: No module named 'application' или web: Failed to find attribute 'application' in 'application'.

другие файлы пустые, потому что я пробовал с моим проектом, и теперь я пытаюсь с пустым.

django.конфигурация

 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()
 

это мои файлы:

введите описание изображения здесь

Бревна:

 
----------------------------------------
/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
 

Комментарии:

1. Вы используете Amazon Linux 1 или Amazon Linux 2? К сожалению, конфигурационный файл должен отличаться в зависимости от используемой версии.

2. Amazon Linux 2, мне не хватает какого-то файла?

3. Можете ли вы показать содержимое eb logs ?

4. Вы зафиксировали все эти файлы ? Если вы инициализировали git для своего проекта, он развертывает последнюю фиксацию из текущей ветви — docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb3-cli-git.html

5. я пробовал раньше и пробовал вчера тоже, все та же проблема.

Ответ №1:

Попробуйте, если вы используете mac, убедитесь, что вы архивируете файлы, а не на уровне lop.

https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/applications-sourcebundle.html