简体   繁体   中英

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

In my django app white noise is acted on in the following ways:

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

and

STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'

I am deploying a django application to heroku. I am getting the following errors. White noise is installed successfully.

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

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

with my stack trace below. I am including the full stacktrace so that the full situation can be appreciated. In truth I am not sure what is going on right now and its rather fustrating. Heroku as been fighting me all day.

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

I have too much code in my question according to stackoverflow. So here is a cute poem since I have nothing else to say.

Whenevel I clied hungly, Chhe would give me milk. Whenevel I do not dlink it, Chhe will tly that I dlink it. Whenevel I am chho angly, Chhe will tly that I dlunk it. Whenevel chhe loshesh hope, Chhe will look at my papa. My daddy will only shmile, Lift shweetly in hiz armsh.

They would then shuksheed, Togethel they enteltain me. They dichhtract & feed me, Milk I lyk not chho vely hot. Twichhe they tly & I leject, They sing me some lhymsh. Mom then poulsh two dlops, On back of hel hand chhe tlies.

'Tsch! It's hot,' chhe ekchclaims, I let out a shmall shlieky laugh. Daddy lent hel a helping hand, He blung a khup of cold watel. Finally they togethel feed me, Calefully & lovingly they do it. Whenevel I lemembel my lisp, I am chho happy & smile bloadly.

'whitenoise.middleware.WhiteNoiseMiddleWare',

should be

'whitenoise.middleware.WhiteNoiseMiddleware',

make the W lower case to w.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM