heroku 导入错误:模块“whitenoise.middleware”未定义“WhiteNoiseMiddleWare”属性/类

vatpfxk5  于 2022-11-13  发布在  其他
关注(0)|答案(1)|浏览(83)

在我的django应用中,白噪声的作用方式如下:

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'whitenoise.middleware.WhiteNoiseMiddleWare',

STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'

我正在部署一个django应用程序到heroku。我得到了以下错误。白色噪音安装成功。

[2018-03-27 01:38:12 +0000] [9] [ERROR] Exception in worker process

ImportError: Module "whitenoise.middleware" does not define a "WhiteNoiseMiddleWare" attribute/class

下面是我的堆栈跟踪。我包括了完整的堆栈跟踪,以便了解完整的情况。事实上,我不知道现在发生了什么,这相当令人沮丧。Heroku整天都在和我战斗。

File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 244, in handle_chld
2018-03-27T01:38:04.953208+00:00 app[web.1]:     self.reap_workers()
2018-03-27T01:38:04.953232+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 524, in reap_workers
2018-03-27T01:38:04.953390+00:00 app[web.1]:     raise HaltServer(reason, self.WORKER_BOOT_ERROR)
2018-03-27T01:38:04.953555+00:00 app[web.1]: gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
2018-03-27T01:38:05.121702+00:00 heroku[web.1]: State changed from starting to crashed
2018-03-27T01:38:05.123683+00:00 heroku[web.1]: State changed from crashed to starting
2018-03-27T01:38:05.074667+00:00 heroku[web.1]: Process exited with status 1
2018-03-27T01:38:10.266716+00:00 heroku[web.1]: Starting process with command `gunicorn suitsandtables.wsgi`
2018-03-27T01:38:11.983802+00:00 app[web.1]: [2018-03-27 01:38:11 +0000] [4] [INFO] Starting gunicorn 19.7.1
2018-03-27T01:38:11.984195+00:00 app[web.1]: [2018-03-27 01:38:11 +0000] [4] [INFO] Listening at: http://0.0.0.0:22820 (4)
2018-03-27T01:38:11.989226+00:00 app[web.1]: [2018-03-27 01:38:11 +0000] [9] [INFO] Booting worker with pid: 9
2018-03-27T01:38:11.984378+00:00 app[web.1]: [2018-03-27 01:38:11 +0000] [4] [INFO] Using worker: sync
2018-03-27T01:38:12.228871+00:00 app[web.1]:   """)
2018-03-27T01:38:12.085054+00:00 app[web.1]: [2018-03-27 01:38:12 +0000] [11] [INFO] Booting worker with pid: 11
2018-03-27T01:38:12.228867+00:00 app[web.1]: /app/.heroku/python/lib/python2.7/site-packages/psycopg2/__init__.py:144: UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use "pip install psycopg2-binary" instead. For details see: <http://initd.org/psycopg/docs/install.html#binary-install-from-pypi>.
2018-03-27T01:38:12.322208+00:00 app[web.1]: [2018-03-27 01:38:12 +0000] [9] [ERROR] Exception in worker process
2018-03-27T01:38:12.322248+00:00 app[web.1]: Traceback (most recent call last):
2018-03-27T01:38:12.322251+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 578, in spawn_worker
2018-03-27T01:38:12.322253+00:00 app[web.1]:     worker.init_process()
2018-03-27T01:38:12.322255+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/base.py", line 126, in init_process
2018-03-27T01:38:12.322257+00:00 app[web.1]:     self.load_wsgi()
2018-03-27T01:38:12.322258+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/base.py", line 135, in load_wsgi
2018-03-27T01:38:12.322260+00:00 app[web.1]:     self.wsgi = self.app.wsgi()
2018-03-27T01:38:12.322262+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
2018-03-27T01:38:12.322264+00:00 app[web.1]:     self.callable = self.load()
2018-03-27T01:38:12.322265+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
2018-03-27T01:38:12.322267+00:00 app[web.1]:     return self.load_wsgiapp()
2018-03-27T01:38:12.322268+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
2018-03-27T01:38:12.322270+00:00 app[web.1]:     return util.import_app(self.app_uri)
2018-03-27T01:38:12.322272+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/util.py", line 352, in import_app
2018-03-27T01:38:12.322273+00:00 app[web.1]:     __import__(module)
2018-03-27T01:38:12.322275+00:00 app[web.1]:   File "/app/suitsandtables/wsgi.py", line 18, in <module>
2018-03-27T01:38:12.322277+00:00 app[web.1]:     application = get_wsgi_application()
2018-03-27T01:38:12.322280+00:00 app[web.1]:     return WSGIHandler()
2018-03-27T01:38:12.322279+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/core/wsgi.py", line 14, in get_wsgi_application
2018-03-27T01:38:12.322282+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 151, in __init__
2018-03-27T01:38:12.322283+00:00 app[web.1]:     self.load_middleware()
2018-03-27T01:38:12.322285+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/base.py", line 80, in load_middleware
2018-03-27T01:38:12.322287+00:00 app[web.1]:     middleware = import_string(middleware_path)
2018-03-27T01:38:12.322289+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/utils/module_loading.py", line 27, in import_string
2018-03-27T01:38:12.322291+00:00 app[web.1]:     six.reraise(ImportError, ImportError(msg), sys.exc_info()[2])
2018-03-27T01:38:12.322292+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/utils/module_loading.py", line 23, in import_string
2018-03-27T01:38:12.322294+00:00 app[web.1]:     return getattr(module, class_name)
2018-03-27T01:38:12.322296+00:00 app[web.1]: ImportError: Module "whitenoise.middleware" does not define a "WhiteNoiseMiddleWare" attribute/class
2018-03-27T01:38:12.322297+00:00 app[web.1]: [2018-03-27 01:38:12 +0000] [9] [INFO] Worker exiting (pid: 9)
2018-03-27T01:38:12.334355+00:00 app[web.1]: /app/.heroku/python/lib/python2.7/site-packages/psycopg2/__init__.py:144: UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use "pip install psycopg2-binary" instead. For details see: <http://initd.org/psycopg/docs/install.html#binary-install-from-pypi>.
2018-03-27T01:38:12.334361+00:00 app[web.1]:   """)
2018-03-27T01:38:12.428859+00:00 app[web.1]: [2018-03-27 01:38:12 +0000] [11] [ERROR] Exception in worker process
2018-03-27T01:38:12.428864+00:00 app[web.1]: Traceback (most recent call last):
2018-03-27T01:38:12.428874+00:00 app[web.1]:     worker.init_process()
2018-03-27T01:38:12.428869+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 578, in spawn_worker
2018-03-27T01:38:12.428876+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/base.py", line 126, in init_process
2018-03-27T01:38:12.428878+00:00 app[web.1]:     self.load_wsgi()
2018-03-27T01:38:12.428879+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/base.py", line 135, in load_wsgi
2018-03-27T01:38:12.428881+00:00 app[web.1]:     self.wsgi = self.app.wsgi()
2018-03-27T01:38:12.428884+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
2018-03-27T01:38:12.428885+00:00 app[web.1]:     self.callable = self.load()
2018-03-27T01:38:12.428887+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
2018-03-27T01:38:12.428889+00:00 app[web.1]:     return self.load_wsgiapp()
2018-03-27T01:38:12.428891+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
2018-03-27T01:38:12.428892+00:00 app[web.1]:     return util.import_app(self.app_uri)
2018-03-27T01:38:12.428894+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/util.py", line 352, in import_app
2018-03-27T01:38:12.428896+00:00 app[web.1]:     __import__(module)
2018-03-27T01:38:12.428898+00:00 app[web.1]:   File "/app/suitsandtables/wsgi.py", line 18, in <module>
2018-03-27T01:38:12.428900+00:00 app[web.1]:     application = get_wsgi_application()
2018-03-27T01:38:12.428901+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/core/wsgi.py", line 14, in get_wsgi_application
2018-03-27T01:38:12.428903+00:00 app[web.1]:     return WSGIHandler()
2018-03-27T01:38:12.428904+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 151, in __init__
2018-03-27T01:38:12.428906+00:00 app[web.1]:     self.load_middleware()
2018-03-27T01:38:12.428911+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/base.py", line 80, in load_middleware
2018-03-27T01:38:12.428913+00:00 app[web.1]:     middleware = import_string(middleware_path)
2018-03-27T01:38:12.428914+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/utils/module_loading.py", line 27, in import_string
2018-03-27T01:38:12.428916+00:00 app[web.1]:     six.reraise(ImportError, ImportError(msg), sys.exc_info()[2])
2018-03-27T01:38:12.428918+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/django/utils/module_loading.py", line 23, in import_string
2018-03-27T01:38:12.428919+00:00 app[web.1]:     return getattr(module, class_name)
2018-03-27T01:38:12.428921+00:00 app[web.1]: ImportError: Module "whitenoise.middleware" does not define a "WhiteNoiseMiddleWare" attribute/class
2018-03-27T01:38:12.428929+00:00 app[web.1]: [2018-03-27 01:38:12 +0000] [11] [INFO] Worker exiting (pid: 11)
2018-03-27T01:38:12.466856+00:00 app[web.1]: Traceback (most recent call last):
2018-03-27T01:38:12.466859+00:00 app[web.1]:   File "/app/.heroku/python/bin/gunicorn", line 11, in <module>
2018-03-27T01:38:12.466931+00:00 app[web.1]:     sys.exit(run())
2018-03-27T01:38:12.467000+00:00 app[web.1]:     WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
2018-03-27T01:38:12.466940+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 74, in run
2018-03-27T01:38:12.467006+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/base.py", line 203, in run
2018-03-27T01:38:12.467075+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/base.py", line 72, in run
2018-03-27T01:38:12.467069+00:00 app[web.1]:     super(Application, self).run()
2018-03-27T01:38:12.467107+00:00 app[web.1]:     Arbiter(self).run()
2018-03-27T01:38:12.467112+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 231, in run
2018-03-27T01:38:12.467162+00:00 app[web.1]:     self.halt(reason=inst.reason, exit_status=inst.exit_status)
2018-03-27T01:38:12.467164+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 344, in halt
2018-03-27T01:38:12.467225+00:00 app[web.1]:     self.stop()
2018-03-27T01:38:12.467230+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 393, in stop
2018-03-27T01:38:12.467293+00:00 app[web.1]:     time.sleep(0.1)
2018-03-27T01:38:12.467295+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 244, in handle_chld
2018-03-27T01:38:12.467347+00:00 app[web.1]:   File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 524, in reap_workers
2018-03-27T01:38:12.467344+00:00 app[web.1]:     self.reap_workers()
2018-03-27T01:38:12.467425+00:00 app[web.1]:     raise HaltServer(reason, self.WORKER_BOOT_ERROR)
2018-03-27T01:38:12.467482+00:00 app[web.1]: gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
2018-03-27T01:38:12.543505+00:00 heroku[web.1]: Process exited with status 1
2018-03-27T01:38:12.564292+00:00 heroku[web.1]: State changed from starting to crashed
e0bqpujr

e0bqpujr1#

'whitenoise.middleware.WhiteNoiseMiddleWare',

应该是

'whitenoise.middleware.WhiteNoiseMiddleware',

将W小写为w。

相关问题