gpt4 book ai didi

python - 模块未找到错误 : No module named 'application' [Deploying Django to AWS]

转载 作者:行者123 更新时间:2023-12-05 05:56:00 28 4
gpt4 key购买 nike

我一直在尝试从 AWS 在 ElasticBeanstalk 上部署 Django 应用程序。

我关注了this教程大概 6 或 7 次。

尝试以任何一种方式从 Linux 和 Windows 机器进行部署,我最终得到:ModuleNotFoundError:没有名为“application”的模块web:无法在“application”中找到属性“application”。

其他文件是空白的,因为我已经尝试过我的一个项目,现在我正在尝试一个空白的。

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

这些是我的文件:

enter image description here

日志:


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

最佳答案

尝试如果您使用的是 Mac,请确保您正在压缩文件,不在顶层。

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

关于python - 模块未找到错误 : No module named 'application' [Deploying Django to AWS],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69319779/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com