关于heroku的django:ImportError:无法导入名称get_path_info

时间:2014-07-08 03:23:27

标签: python django heroku gunicorn

我没有遇到任何问题在本地运行我的django应用程序,但由于某些原因我在heroku上收到错误ImportError: cannot import name get_path_info,并且不知道如何解决这个问题。

这是我的heroku日志:

    2014-07-07 18:45:45 [18423] [INFO] Starting gunicorn 0.13.4
    2014-07-07 18:45:45 [18424] [ERROR] Exception in worker process:
    Traceback (most recent call last):
      File "/lib/python2.7/site-packages/gunicorn/arbiter.py", line 456, in spawn_worker
        worker.init_process()
      File "/lib/python2.7/site-packages/gunicorn/workers/base.py", line 100, in init_process
        self.wsgi = self.app.wsgi()
      File "/lib/python2.7/site-packages/gunicorn/app/base.py", line 101, in wsgi
        self.callable = self.load()
      File "/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 24, in load
        return util.import_app(self.app_uri)
      File "/lib/python2.7/site-packages/gunicorn/util.py", line 241, in import_app
        __import__(module)
      File "/app/wsgi.py", line 2, in <module>
        from dj_static import Cling
      File "/lib/python2.7/site-packages/dj_static.py", line 7, in <module>
        from django.core.handlers.base import get_path_info
    ImportError: cannot import name get_path_info
    2014-07-07 18:45:45 [18424] [INFO] Worker exiting (pid: 18424)
    18:45:46 web.1  | 2014-07-07 18:45:46 [18423] [INFO] Shutting down: Master
    18:45:46 web.1  | 2014-07-07 18:45:46 [18423] [INFO] Reason: Worker failed to boot.

我的procfile:

web: gunicorn app.wsgi

和我的app / wsgi.py文件:

from django.core.wsgi import get_wsgi_application
from dj_static import Cling
application = Cling(get_wsgi_application())

2 个答案:

答案 0 :(得分:1)

尝试在Virtualenv requirements.txt文件中设置dj-static==0.0.6。 Heroku Django教程目前显示为0.0.5。您可能在本地运行0.0.6但在Heroku中运行。

我已将此问题报告给Heroku,他们的教程现已更新,以反映requirements.txt中的较新版本。

答案 1 :(得分:0)

尝试以下3个步骤:

  1. 安装最新版本的dj-static(pip install dj-static==0.0.6)。

  2. 安装Heroku工具包(pip install django-toolbet)。

  3. 确保requirements.txt文件已更新。