我在Heroku上部署了一个Django项目。该项目在我的本地服务器上运行。但是在部署之后,我看到以下错误:“内部服务器错误”
Heroku的日志堆栈如下:
2013-04-20T23:40:14.546579+00:00 heroku[web.1]: Idling
2013-04-20T23:40:17.581159+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2013-04-20T23:40:18.345471+00:00 app[web.1]: 2013-04-20 18:40:18 [7] [INFO] Worker exiting (pid: 7)
2013-04-20T23:40:18.346329+00:00 app[web.1]: 2013-04-20 23:40:18 [2] [INFO] Handling signal: term
2013-04-20T23:40:18.477876+00:00 app[web.1]: 2013-04-20 23:40:18 [2] [INFO] Shutting down: Master
2013-04-20T23:40:19.736712+00:00 heroku[web.1]: Process exited with status 0
2013-04-20T23:40:19.745601+00:00 heroku[web.1]: State changed from up to down
2013-04-21T06:01:40.398237+00:00 heroku[web.1]: State changed from down to starting
2013-04-21T06:01:40.395347+00:00 heroku[web.1]: Unidling
2013-04-21T06:01:44.127852+00:00 heroku[web.1]: Starting process with command `gunicorn dreamport.wsgi`
2013-04-21T06:01:44.947306+00:00 app[web.1]: 2013-04-21 06:01:44 [2] [INFO] Listening at: http://0.0.0.0:16642 (2)
2013-04-21T06:01:44.947410+00:00 app[web.1]: 2013-04-21 06:01:44 [2] [INFO] Using worker: sync
2013-04-21T06:01:44.946487+00:00 app[web.1]: 2013-04-21 06:01:44 [2] [INFO] Starting gunicorn 0.17.2
2013-04-21T06:01:44.951885+00:00 app[web.1]: 2013-04-21 06:01:44 [7] [INFO] Booting worker with pid: 7
2013-04-21T06:01:45.319576+00:00 heroku[web.1]: State changed from starting to up
2013-04-21T06:01:46.272244+00:00 app[web.1]: self.load_middleware()
2013-04-21T06:01:46.272244+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/sync.py", line 125, in handle_request
2013-04-21T06:01:46.272244+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/base.py", line 53, in load_middleware
2013-04-21T06:01:46.272244+00:00 app[web.1]: 2013-04-21 01:01:46 [7] [ERROR] Error handling request
2013-04-21T06:01:46.272244+00:00 app[web.1]: raise exceptions.ImproperlyConfigured('Error importing middleware %s: "%s"' % (mw_module, e))
2013-04-21T06:01:46.272244+00:00 app[web.1]: Traceback (most recent call last):
2013-04-21T06:01:46.272244+00:00 app[web.1]: ImproperlyConfigured: Error importing middleware django.contrib.auth.middleware: "No module named psycopg2.extensions"
2013-04-21T06:01:46.272244+00:00 app[web.1]: respiter = self.wsgi(environ, resp.start_response)
2013-04-21T06:01:46.272244+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 236, in __call__
2013-04-21T06:01:46.276829+00:00 heroku[router]: at=info method=GET path=/crawl/ host=whispering-sierra-7921.herokuapp.com fwd="1.22.41.124" dyno=web.1 connect=1ms service=33ms status=500 bytes=135
2013-04-21T06:01:46.454282+00:00 heroku[router]: at=info method=GET path=/crawl/ host=whispering-sierra-7921.herokuapp.com fwd="1.22.41.124" dyno=web.1 connect=1ms service=7ms status=500 bytes=135
2013-04-21T06:01:46.453789+00:00 app[web.1]: ImproperlyConfigured: Error importing middleware django.contrib.auth.middleware: "cannot import name utils"
2013-04-21T06:01:46.453789+00:00 app[web.1]: 2013-04-21 01:01:46 [7] [ERROR] Error handling request
2013-04-21T06:01:46.453789+00:00 app[web.1]: Traceback (most recent call last):
2013-04-21T06:01:46.453789+00:00 app[web.1]: raise exceptions.ImproperlyConfigured('Error importing middleware %s: "%s"' % (mw_module, e))
2013-04-21T06:01:46.453789+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/base.py", line 53, in load_middleware
2013-04-21T06:01:46.453789+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/sync.py", line 125, in handle_request
2013-04-21T06:01:46.453789+00:00 app[web.1]: respiter = self.wsgi(environ, resp.start_response)
2013-04-21T06:01:46.453789+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 236, in __call__
2013-04-21T06:01:46.453789+00:00 app[web.1]: self.load_middleware()
2013-04-21T06:01:46.919825+00:00 app[web.1]: self.load_middleware()
2013-04-21T06:01:46.919825+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/sync.py", line 125, in handle_request
2013-04-21T06:01:46.919825+00:00 app[web.1]: 2013-04-21 01:01:46 [7] [ERROR] Error handling request
2013-04-21T06:01:46.919825+00:00 app[web.1]: Traceback (most recent call last):
2013-04-21T06:01:46.919825+00:00 app[web.1]: respiter = self.wsgi(environ, resp.start_response)
2013-04-21T06:01:46.919825+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 236, in __call__
2013-04-21T06:01:46.919825+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/base.py", line 53, in load_middleware
2013-04-21T06:01:46.919825+00:00 app[web.1]: raise exceptions.ImproperlyConfigured('Error importing middleware %s: "%s"' % (mw_module, e))
2013-04-21T06:01:46.919825+00:00 app[web.1]: ImproperlyConfigured: Error importing middleware django.contrib.auth.middleware: "cannot import name utils"
2013-04-21T06:01:46.922735+00:00 heroku[router]: at=info method=GET path=/favicon.ico host=whispering-sierra-7921.herokuapp.com fwd="1.22.41.124" dyno=web.1 connect=2ms service=7ms status=500 bytes=135
2013-04-21T06:01:47.159726+00:00 app[web.1]: raise exceptions.ImproperlyConfigured('Error importing middleware %s: "%s"' % (mw_module, e))
2013-04-21T06:01:47.159726+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/sync.py", line 125, in handle_request
2013-04-21T06:01:47.159726+00:00 app[web.1]: self.load_middleware()
2013-04-21T06:01:47.159726+00:00 app[web.1]: ImproperlyConfigured: Error importing middleware django.contrib.auth.middleware: "cannot import name utils"
2013-04-21T06:01:47.159726+00:00 app[web.1]: 2013-04-21 01:01:47 [7] [ERROR] Error handling request
2013-04-21T06:01:47.159726+00:00 app[web.1]: respiter = self.wsgi(environ, resp.start_response)
2013-04-21T06:01:47.159726+00:00 app[web.1]: Traceback (most recent call last):
2013-04-21T06:01:47.159726+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 236, in __call__
2013-04-21T06:01:47.159726+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/base.py", line 53, in load_middleware
2013-04-21T06:01:47.163309+00:00 heroku[router]: at=info method=GET path=/favicon.ico host=whispering-sierra-7921.herokuapp.com fwd="1.22.41.124" dyno=web.1 connect=1ms service=7ms status=500 bytes=135
2013-04-21T06:11:38.726802+00:00 app[web.1]: raise exceptions.ImproperlyConfigured('Error importing middleware %s: "%s"' % (mw_module, e))
2013-04-21T06:11:38.726802+00:00 app[web.1]: Traceback (most recent call last):
2013-04-21T06:11:38.726802+00:00 app[web.1]: respiter = self.wsgi(environ, resp.start_response)
2013-04-21T06:11:38.726802+00:00 app[web.1]: ImproperlyConfigured: Error importing middleware django.contrib.auth.middleware: "cannot import name utils"
2013-04-21T06:11:38.726802+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 236, in __call__
2013-04-21T06:11:38.726802+00:00 app[web.1]: 2013-04-21 01:11:38 [7] [ERROR] Error handling request
2013-04-21T06:11:38.726802+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/sync.py", line 125, in handle_request
2013-04-21T06:11:38.726802+00:00 app[web.1]: self.load_middleware()
2013-04-21T06:11:38.726802+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/base.py", line 53, in load_middleware
2013-04-21T06:11:38.729075+00:00 heroku[router]: at=info method=GET path=/ host=dreamport.herokuapp.com fwd="1.22.41.124" dyno=web.1 connect=0ms service=5ms status=500 bytes=135
2013-04-21T06:11:39.020870+00:00 app[web.1]: respiter = self.wsgi(environ, resp.start_response)
2013-04-21T06:11:39.020870+00:00 app[web.1]: self.load_middleware()
2013-04-21T06:11:39.020870+00:00 app[web.1]: ImproperlyConfigured: Error importing middleware django.contrib.auth.middleware: "cannot import name utils"
2013-04-21T06:11:39.020870+00:00 app[web.1]: 2013-04-21 01:11:39 [7] [ERROR] Error handling request
2013-04-21T06:11:39.020870+00:00 app[web.1]: Traceback (most recent call last):
2013-04-21T06:11:39.020870+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/base.py", line 53, in load_middleware
2013-04-21T06:11:39.020870+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/sync.py", line 125, in handle_request
2013-04-21T06:11:39.020870+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 236, in __call__
2013-04-21T06:11:39.020870+00:00 app[web.1]: raise exceptions.ImproperlyConfigured('Error importing middleware %s: "%s"' % (mw_module, e))
2013-04-21T06:11:39.243692+00:00 app[web.1]: respiter = self.wsgi(environ, resp.start_response)
2013-04-21T06:11:39.243692+00:00 app[web.1]: 2013-04-21 01:11:39 [7] [ERROR] Error handling request
2013-04-21T06:11:39.243692+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 236, in __call__
2013-04-21T06:11:39.243692+00:00 app[web.1]: Traceback (most recent call last):
2013-04-21T06:11:39.243692+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/sync.py", line 125, in handle_request
2013-04-21T06:11:39.246133+00:00 heroku[router]: at=info method=GET path=/favicon.ico host=dreamport.herokuapp.com fwd="1.22.41.124" dyno=web.1 connect=0ms service=6ms status=500 bytes=135
2013-04-21T06:11:39.243692+00:00 app[web.1]: self.load_middleware()
2013-04-21T06:11:39.243692+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/base.py", line 53, in load_middleware
2013-04-21T06:11:39.243692+00:00 app[web.1]: raise exceptions.ImproperlyConfigured('Error importing middleware %s: "%s"' % (mw_module, e))
2013-04-21T06:11:39.243692+00:00 app[web.1]: ImproperlyConfigured: Error importing middleware django.contrib.auth.middleware: "cannot import name utils"
2013-04-21T06:12:04.120575+00:00 app[web.1]: 2013-04-21 01:12:04 [7] [ERROR] Error handling request
2013-04-21T06:12:04.120575+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/base.py", line 53, in load_middleware
2013-04-21T06:12:04.120575+00:00 app[web.1]: respiter = self.wsgi(environ, resp.start_response)
2013-04-21T06:12:04.120575+00:00 app[web.1]: Traceback (most recent call last):
2013-04-21T06:12:04.120575+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/sync.py", line 125, in handle_request
2013-04-21T06:12:04.120575+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 236, in __call__
2013-04-21T06:12:04.120575+00:00 app[web.1]: self.load_middleware()
2013-04-21T06:12:04.120575+00:00 app[web.1]: ImproperlyConfigured: Error importing middleware django.contrib.auth.middleware: "cannot import name utils"
2013-04-21T06:12:04.120575+00:00 app[web.1]: raise exceptions.ImproperlyConfigured('Error importing middleware %s: "%s"' % (mw_module, e))
2013-04-21T06:12:04.123292+00:00 heroku[router]: at=info method=GET path=/ host=dreamport.herokuapp.com fwd="1.22.41.124" dyno=web.1 connect=2ms service=11ms status=500 bytes=135
2013-04-21T07:14:21.517338+00:00 heroku[web.1]: Idling
2013-04-21T07:14:25.228488+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2013-04-21T07:14:26.207781+00:00 app[web.1]: 2013-04-21 02:14:26 [7] [INFO] Worker exiting (pid: 7)
2013-04-21T07:14:26.207991+00:00 app[web.1]: 2013-04-21 07:14:26 [2] [INFO] Handling signal: term
2013-04-21T07:14:26.340352+00:00 app[web.1]: 2013-04-21 07:14:26 [2] [INFO] Shutting down: Master
2013-04-21T07:14:27.603296+00:00 heroku[web.1]: Process exited with status 0
2013-04-21T07:14:27.615792+00:00 heroku[web.1]: State changed from up to down
我哪里错了?
答案 0 :(得分:2)
似乎没有为您的实例正确配置postgresql:"No module named psycopg2.extensions"
。请阅读Heroku的devcenter上的this excellent post,其中详细说明了如何为您的实例启用postgresql。它甚至包括django的具体步骤。