gpt4 book ai didi

python - Gunicorn ImportError : No module named application

转载 作者:行者123 更新时间:2023-12-02 20:38:44 25 4
gpt4 key购买 nike

嗨,我正在学习本教程 https://semaphoreci.com/community/tutorials/dockerizing-a-python-django-web-application关于如何在 docker 上部署一个 Django 项目,在某些时候你必须开始使用 gunicorn
我的 start.sh 是这样的。

#!/bin/bash

#start gunicorn processes

echo "starting gunicorn for wrappers"

exec gunicorn sparqlwrapper.wsgi.application --bind 0.0.0.0:8000 --workers 5

但是当我运行 start.sh 我得到这个错误
starting gunicorn  for wrappers
[2017-09-28 12:47:05 +0000] [28740] [INFO] Starting gunicorn 19.7.1
[2017-09-28 12:47:05 +0000] [28740] [INFO] Listening at: http://0.0.0.0:8000 (28740)
[2017-09-28 12:47:05 +0000] [28740] [INFO] Using worker: sync
[2017-09-28 12:47:05 +0000] [28745] [INFO] Booting worker with pid: 28745
[2017-09-28 12:47:05 +0000] [28746] [INFO] Booting worker with pid: 28746
[2017-09-28 12:47:05 +0000] [28747] [INFO] Booting worker with pid: 28747
[2017-09-28 12:47:05 +0000] [28745] [ERROR] Exception in worker process
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/gunicorn/arbiter.py", line 578, in spawn_worker
worker.init_process()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/workers/base.py", line 126, in init_process
self.load_wsgi()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/workers/base.py", line 135, in load_wsgi
self.wsgi = self.app.wsgi()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/wsgiapp.py", line 65, in load
return self.load_wsgiapp()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
return util.import_app(self.app_uri)
File "/usr/local/lib/python2.7/dist-packages/gunicorn/util.py", line 352, in import_app
__import__(module)
ImportError: No module named application
[2017-09-28 12:47:05 +0000] [28745] [INFO] Worker exiting (pid: 28745)
[2017-09-28 12:47:05 +0000] [28746] [ERROR] Exception in worker process
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/gunicorn/arbiter.py", line 578, in spawn_worker
worker.init_process()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/workers/base.py", line 126, in init_process
self.load_wsgi()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/workers/base.py", line 135, in load_wsgi
self.wsgi = self.app.wsgi()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/wsgiapp.py", line 65, in load
return self.load_wsgiapp()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
return util.import_app(self.app_uri)
File "/usr/local/lib/python2.7/dist-packages/gunicorn/util.py", line 352, in import_app
__import__(module)
ImportError: No module named application
[2017-09-28 12:47:05 +0000] [28746] [INFO] Worker exiting (pid: 28746)
Traceback (most recent call last):
File "/usr/local/bin/gunicorn", line 11, in <module>
sys.exit(run())
File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/wsgiapp.py", line 74, in run
WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/base.py", line 203, in run
super(Application, self).run()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/base.py", line 72, in run
Arbiter(self).run()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/arbiter.py", line 231, in run
self.halt(reason=inst.reason, exit_status=inst.exit_status)
File "/usr/local/lib/python2.7/dist-packages/gunicorn/arbiter.py", line 344, in halt
self.stop()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/arbiter.py", line 393, in stop
time.sleep(0.1)
File "/usr/local/lib/python2.7/dist-packages/gunicorn/arbiter.py", line 244, in handle_chld
self.reap_workers()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/arbiter.py", line 524, in reap_workers
raise HaltServer(reason, self.WORKER_BOOT_ERROR)
gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
[2017-09-28 12:47:05 +0000] [28747] [ERROR] Exception in worker process
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/gunicorn/arbiter.py", line 578, in spawn_worker
worker.init_process()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/workers/base.py", line 126, in init_process
self.load_wsgi()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/workers/base.py", line 135, in load_wsgi
self.wsgi = self.app.wsgi()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/wsgiapp.py", line 65, in load
return self.load_wsgiapp()
File "/usr/local/lib/python2.7/dist-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
return util.import_app(self.app_uri)
File "/usr/local/lib/python2.7/dist-packages/gunicorn/util.py", line 352, in import_app
__import__(module)
ImportError: No module named application
[2017-09-28 12:47:05 +0000] [28747] [INFO] Worker exiting (pid: 28747)

当我使用 python manage.py runserver 0.0.0.0:8000 运行项目时,它确实可以工作,所以它必须是 gunicorn 本身

最佳答案

application对象不是模块;您应该使用冒号而不是句点将其与所在的模块分开。

exec gunicorn sparqlwrapper.wsgi:application --bind 0.0.0.0:8000  --workers 5

关于python - Gunicorn ImportError : No module named application,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46466380/

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