Django / gunicorn:ImportError:无法导入名称get_path_info

时间:2014-05-12 23:34:41

标签: django gunicorn

我安装了我正在尝试运行的项目的要求,并且安装得很好。然后我开始工头开始,我得到了这个错误,我无法理解这里的问题。有任何想法吗?我尝试卸载并重新安装dj_static,似乎没有什么区别。

(venv)$ foreman start
    16:28:12 web.1  | started with pid 29309
    16:28:12 web.1  | 2014-05-12 16:28:12 [29309] [INFO] Starting gunicorn 18.0
    16:28:12 web.1  | 2014-05-12 16:28:12 [29309] [INFO] Listening at: http://0.0.0.0:5000 (29309)
    16:28:12 web.1  | 2014-05-12 16:28:12 [29309] [INFO] Using worker: sync
    16:28:12 web.1  | 2014-05-12 16:28:12 [29312] [INFO] Booting worker with pid: 29312
    16:28:12 web.1  | 2014-05-12 16:28:12 [29312] [ERROR] Exception in worker process:
    16:28:12 web.1  | Traceback (most recent call last):
    16:28:12 web.1  |   File "/Library/Python/2.7/site-packages/gunicorn/arbiter.py", line 495, in spawn_worker
    16:28:12 web.1  |     worker.init_process()
    16:28:12 web.1  |   File "/Library/Python/2.7/site-packages/gunicorn/workers/base.py", line 106, in init_process
    16:28:12 web.1  |     self.wsgi = self.app.wsgi()
    16:28:12 web.1  |   File "/Library/Python/2.7/site-packages/gunicorn/app/base.py", line 114, in wsgi
    16:28:12 web.1  |     self.callable = self.load()
    16:28:12 web.1  |   File "/Library/Python/2.7/site-packages/gunicorn/app/wsgiapp.py", line 62, in load
    16:28:12 web.1  |     return self.load_wsgiapp()
    16:28:12 web.1  |   File "/Library/Python/2.7/site-packages/gunicorn/app/wsgiapp.py", line 49, in load_wsgiapp
    16:28:12 web.1  |     return util.import_app(self.app_uri)
    16:28:12 web.1  |   File "/Library/Python/2.7/site-packages/gunicorn/util.py", line 354, in import_app
    16:28:12 web.1  |     __import__(module)
    16:28:12 web.1  |   File "/Users/n/wppdashboard/dashboard/wsgi.py", line 25, in <module>
    16:28:12 web.1  |     from dj_static import Cling
    16:28:12 web.1  |   File "/Library/Python/2.7/site-packages/dj_static.py", line 7, in <module>
    16:28:12 web.1  |     from django.core.handlers.base import get_path_info
    16:28:12 web.1  | ImportError: cannot import name get_path_info
    16:28:12 web.1  | Traceback (most recent call last):
    16:28:12 web.1  |   File "/Library/Python/2.7/site-packages/gunicorn/arbiter.py", line 495, in spawn_worker
    16:28:12 web.1  |     worker.init_process()
    16:28:12 web.1  |   File "/Library/Python/2.7/site-packages/gunicorn/workers/base.py", line 106, in init_process
    16:28:12 web.1  |     self.wsgi = self.app.wsgi()
    16:28:12 web.1  |   File "/Library/Python/2.7/site-packages/gunicorn/app/base.py", line 114, in wsgi
    16:28:12 web.1  |     self.callable = self.load()
    16:28:12 web.1  |   File "/Library/Python/2.7/site-packages/gunicorn/app/wsgiapp.py", line 62, in load
    16:28:12 web.1  |     return self.load_wsgiapp()
    16:28:12 web.1  |   File "/Library/Python/2.7/site-packages/gunicorn/app/wsgiapp.py", line 49, in load_wsgiapp
    16:28:12 web.1  |     return util.import_app(self.app_uri)
    16:28:12 web.1  |   File "/Library/Python/2.7/site-packages/gunicorn/util.py", line 354, in import_app
    16:28:12 web.1  |     __import__(module)
    16:28:12 web.1  |   File "/Users/n/wppdashboard/dashboard/wsgi.py", line 25, in <module>
    16:28:12 web.1  |     from dj_static import Cling
    16:28:12 web.1  |   File "/Library/Python/2.7/site-packages/dj_static.py", line 7, in <module>
    16:28:12 web.1  |     from django.core.handlers.base import get_path_info
    16:28:12 web.1  | ImportError: cannot import name get_path_info
    16:28:12 web.1  | 2014-05-12 16:28:12 [29312] [INFO] Worker exiting (pid: 29312)
    16:28:12 web.1  | 2014-05-12 16:28:12 [29309] [INFO] Shutting down: Master
    16:28:12 web.1  | 2014-05-12 16:28:12 [29309] [INFO] Reason: Worker failed to boot.
    16:28:12 web.1  | exited with code 3
    16:28:12 system | sending SIGTERM to all processes
    SIGTERM received
    (venv)$ 

3 个答案:

答案 0 :(得分:3)

我想出了这个。

我要么安装了两个不同版本,要么在安装中更改了一些文件。只需在您的venv中重新安装django即可。

答案 1 :(得分:3)

对我来说,问题是dj_static 0.0.5似乎没有与Django 1.7很好地配合。我已升级到0.0.6并修复了它。

答案 2 :(得分:0)

我在OpenShift上运行,从Django 1.6升级到1.7时收到了同样的错误。在我的openshiftstaticfiles.py中,我对&#34;进口&#34;进行了以下更改。模块顶部的部分。

try:
    #Django 1.7
    from django.core.handlers.wsgi import get_path_info
except ImportError:
    #Django 1.6
    from django.core.handlers.base import get_path_info

我不认为我正在使用&#39; dj_static&#39;,但它正在使用&#39; static3&#39;,我在根级别中看到&#39; setup.py&#39;文件。