Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.6k views
in Technique[技术] by (71.8m points)

python - Elastic Beanstalk not detecting my WSGIPath - ModuleNotFoundError

I'm attempting to deploy my Odoo instance to Elastic Beanstalk, and I'm getting the following error message:

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'?

This is what I have in my .ebextension config file:

option_settings:
  aws:elasticbeanstalk:container:python:
    WSGIPath: setup/wsgi.py:application

Folder structure:

Odoo
-.ebextensions
-...
-setup
--...
--wsgi.py
-...

I've tried many different ways for solving this but no success:

  • Having the full path to wsgi.py on .ebextensions
  • Renaming the file to a more simple name ("odoo-wsgi.py" to "wsgi.py")
  • Adding /var/app/current to PYTHONPATH

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

According to the gunicorn docs a dot path is required, so this is what I needed to put in WSGIPath:

option_settings:
  aws:elasticbeanstalk:container:python:
    WSGIPath: setup.wsgi:application

Note: This leads to more errors for deploying Odoo, but waiting till I can post again because it's a different question.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...