Elastic Beanstalk 未检测到我的 WSGIPath - ModuleNotFoundError
Posted
技术标签:
【中文标题】Elastic Beanstalk 未检测到我的 WSGIPath - ModuleNotFoundError【英文标题】:Elastic Beanstalk not detecting my WSGIPath - ModuleNotFoundError 【发布时间】:2021-04-17 12:47:51 【问题描述】:我正在尝试将我的 Odoo 实例部署到 Elastic Beanstalk,并且收到以下错误消息:
Jan 11 23:08:24 ip-172-31-31-143 web: ModuleNotFoundError: No module named 'setup/wsgi'
Jan 11 23:08:24 ip-172-31-31-143 web: During handling of the above exception, another exception occurred:
Jan 11 23:08:24 ip-172-31-31-143 web: Traceback (most recent call last):
Jan 11 23:08:24 ip-172-31-31-143 web: File "/var/app/venv/staging-LQM1lest/lib/python3.7/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
Jan 11 23:08:24 ip-172-31-31-143 web: worker.init_process()
Jan 11 23:08:24 ip-172-31-31-143 web: File "/var/app/venv/staging-LQM1lest/lib/python3.7/site-packages/gunicorn/workers/gthread.py", line 92, in init_process
Jan 11 23:08:24 ip-172-31-31-143 web: super().init_process()
Jan 11 23:08:24 ip-172-31-31-143 web: File "/var/app/venv/staging-LQM1lest/lib/python3.7/site-packages/gunicorn/workers/base.py", line 119, in init_process
Jan 11 23:08:24 ip-172-31-31-143 web: self.load_wsgi()
Jan 11 23:08:24 ip-172-31-31-143 web: File "/var/app/venv/staging-LQM1lest/lib/python3.7/site-packages/gunicorn/workers/base.py", line 144, in load_wsgi
Jan 11 23:08:24 ip-172-31-31-143 web: self.wsgi = self.app.wsgi()
Jan 11 23:08:24 ip-172-31-31-143 web: File "/var/app/venv/staging-LQM1lest/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
Jan 11 23:08:24 ip-172-31-31-143 web: self.callable = self.load()
Jan 11 23:08:24 ip-172-31-31-143 web: File "/var/app/venv/staging-LQM1lest/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 49, in load
Jan 11 23:08:24 ip-172-31-31-143 web: return self.load_wsgiapp()
Jan 11 23:08:24 ip-172-31-31-143 web: File "/var/app/venv/staging-LQM1lest/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp
Jan 11 23:08:24 ip-172-31-31-143 web: return util.import_app(self.app_uri)
Jan 11 23:08:24 ip-172-31-31-143 web: File "/var/app/venv/staging-LQM1lest/lib/python3.7/site-packages/gunicorn/util.py", line 362, in import_app
Jan 11 23:08:24 ip-172-31-31-143 web: raise ImportError(msg % (module.rsplit(".", 1)[0], obj))
Jan 11 23:08:24 ip-172-31-31-143 web: ImportError: Failed to find application, did you mean 'setup/wsgi:application'?
这是我的 .ebextension 配置文件中的内容:
option_settings:
aws:elasticbeanstalk:container:python:
WSGIPath: setup/wsgi.py:application
文件夹结构:
Odoo
-.ebextensions
-...
-setup
--...
--wsgi.py
-...
我尝试了许多不同的方法来解决这个问题,但都没有成功:
在 .ebextensions 上有 wsgi.py 的完整路径 将文件重命名为更简单的名称(“odoo-wsgi.py”为“wsgi.py”) 将 /var/app/current 添加到 PYTHONPATH【问题讨论】:
【参考方案1】:根据 gunicorn 文档,点路径是必需的,所以这是我需要放入 WSGIPath 的内容:
option_settings:
aws:elasticbeanstalk:container:python:
WSGIPath: setup.wsgi:application
注意:这会导致部署 Odoo 时出现更多错误,但要等到我可以再次发布,因为这是一个不同的问题。
【讨论】:
以上是关于Elastic Beanstalk 未检测到我的 WSGIPath - ModuleNotFoundError的主要内容,如果未能解决你的问题,请参考以下文章
如何将一个端口从 Elastic Beanstalk 映射到我的 Flask 应用程序的 Docker 容器?
如何将包(例如 libjpeg-dev)自动加载到我的 Elastic Beanstalk 应用程序?
如何获取存储在 Elastic Beanstalk 实例中的文件?
为 Elastic Beanstalk 环境配置 HTTPS