2

我正在尝试在 Ubuntu(EC2 实例)上将我的 django 项目设置为生产环境,但出现以下错误。我的路径是 100% 正确的,并且我已经查找了具有相同类型问题的其他 stackoverflow 问题,但似乎没有任何帮助。我想我可能有不同的问题。

任何人都可以发现任何错误或知道我的问题导致此错误吗?

**运行 Django 1.5

Ubuntu 12.04.2 LTS**

错误:

文件“/usr/local/lib/python2.7/dist-packages/django/conf/_ init _.py”,第 132 行,在 _ init _ raise ImportError("Could not import settings '%s' (是在 sys.path 上?): %s" % (self.SETTINGS_MODULE, e)) [client 37.191.99.202] ImportError: Could not import settings 'live.settings' (它在 sys.path 上吗?): 没有名为 billiard 的模块.例外

wsgi

import os, sys
sys.path.append('/srv/projects/liveSMS')
sys.path.append('/srv/projects/liveSMS.live')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "live.settings")


import django.core.handlers.wsgi

application = django.core.handlers.wsgi.WSGIHandler()

站点(domain.com 不是真正的域)

<VirtualHost *:80>
   ServerName  domain.com
   ServerAlias domain.com

   DocumentRoot /srv/projects/liveSMS/public

   WSGIScriptAlias / /srv/projects/liveSMS/apache/django.wsgi
   <Directory /srv/projects/liveSMS/>
      Order allow,deny
      Allow from all
   </Directory>

    Alias /robots.txt /srv/projects/liveSMS/public/robots.txt
    Alias /static /srv/projects/liveSMS/static

     ErrorLog /srv/projects/liveSMS/logs/error.log
</VirtualHost>

完全错误

[Tue Mar 19 10:31:40 2013] [error] [client 37.191.99.202]     raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
[Tue Mar 19 10:31:40 2013] [error] [client 37.191.99.202] ImportError: Could not import settings 'live/settings' (Is it on sys.path?): Import by filename is not supported.
[Tue Mar 19 10:39:14 2013] [error] [client 37.191.99.202] mod_wsgi (pid=1488): Exception occurred processing WSGI script '/srv/projects/liveSMS/apache/django.wsgi'.
[Tue Mar 19 10:39:14 2013] [error] [client 37.191.99.202] Traceback (most recent call last):
[Tue Mar 19 10:39:14 2013] [error] [client 37.191.99.202]   File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 236, in __call__
[Tue Mar 19 10:39:14 2013] [error] [client 37.191.99.202]     self.load_middleware()
[Tue Mar 19 10:39:14 2013] [error] [client 37.191.99.202]   File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 45, in load_middleware
[Tue Mar 19 10:39:14 2013] [error] [client 37.191.99.202]     for middleware_path in settings.MIDDLEWARE_CLASSES:
[Tue Mar 19 10:39:14 2013] [error] [client 37.191.99.202]   File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 52, in __getattr__
[Tue Mar 19 10:39:14 2013] [error] [client 37.191.99.202]     self._setup(name)
[Tue Mar 19 10:39:14 2013] [error] [client 37.191.99.202]   File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 47, in _setup
[Tue Mar 19 10:39:14 2013] [error] [client 37.191.99.202]     self._wrapped = Settings(settings_module)
[Tue Mar 19 10:39:14 2013] [error] [client 37.191.99.202]   File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 132, in __init__
[Tue Mar 19 10:39:14 2013] [error] [client 37.191.99.202]     raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
[Tue Mar 19 10:39:14 2013] [error] [client 37.191.99.202] ImportError: Could not import settings 'live.settings' (Is it on sys.path?): No module named billiard.exceptions
[Tue Mar 19 11:14:53 2013] [error] [client 37.191.99.202] mod_wsgi (pid=1656): Exception occurred processing WSGI script '/srv/projects/liveSMS/apache/django.wsgi'.
[Tue Mar 19 11:14:53 2013] [error] [client 37.191.99.202] Traceback (most recent call last):
[Tue Mar 19 11:14:53 2013] [error] [client 37.191.99.202]   File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 236, in __call__
[Tue Mar 19 11:14:53 2013] [error] [client 37.191.99.202]     self.load_middleware()
[Tue Mar 19 11:14:53 2013] [error] [client 37.191.99.202]   File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 45, in load_middleware
[Tue Mar 19 11:14:53 2013] [error] [client 37.191.99.202]     for middleware_path in settings.MIDDLEWARE_CLASSES:
[Tue Mar 19 11:14:53 2013] [error] [client 37.191.99.202]   File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 52, in __getattr__
[Tue Mar 19 11:14:53 2013] [error] [client 37.191.99.202]     self._setup(name)
[Tue Mar 19 11:14:53 2013] [error] [client 37.191.99.202]   File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 47, in _setup
[Tue Mar 19 11:14:53 2013] [error] [client 37.191.99.202]     self._wrapped = Settings(settings_module)
[Tue Mar 19 11:14:53 2013] [error] [client 37.191.99.202]   File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 132, in __init__
[Tue Mar 19 11:14:53 2013] [error] [client 37.191.99.202]     raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
[Tue Mar 19 11:14:53 2013] [error] [client 37.191.99.202] ImportError: Could not import settings 'live.settings' (Is it on sys.path?): No module named billiard.exceptions
4

1 回答 1

1

可能在您的配置中,路径 /srv/projects/liveSMS 和 /srv/projects/liveSMS.live 必须位于 PYTHONPATH 变量中。

例如,您可以将其永久添加到启动 Apache 网络服务器的用户的 .bashrc 文件中:

PYTHONPATH='/srv/projects/liveSMS/:/srv/projects/liveSMS.live/'。

我不确定建议的解决方案是最好的。但它可以工作。

于 2013-03-19T12:51:11.593 回答