Django无法加载.wsgi作为Python模块

时间:2015-02-18 19:34:50

标签: django apache wsgi

我正在尝试设置ApacheDjango。我在项目根目录下有django.wsgi文件,其中包含以下内容

import os
import sys

# activate virtualenv
activate_this = os.path.expanduser(
    "/var/www/continue/env-continue/bin/activate_this.py"
)
execfile(activate_this, dict(__file__=activate_this))

PROJECT_DIR = '/var/www/continue/'
APP_PATH = os.path.join(PROJECT_DIR, 'app',).replace('\\', '/'),

sys.path.append(APP_PATH)
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' # also tried 'continue.settings', but same errors appears

# import django.core.handlers.wsgi
# application = django.core.handlers.wsgi.WSGIHandler()
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

但是我在日志文件

中收到以下错误Target WSGI script '/var/www/continue/django.wsgi' cannot be loaded as Python module
  

[Wed Feb 18 14:28:28.273972 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] mod_wsgi(pid = 28781):目标WSGI脚本' / var / WWW /继续/ django.wsgi'无法作为Python模块加载。   [Wed Feb 18 14:28:28.274014 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] mod_wsgi(pid = 28781):处理WSGI脚本' / var / www时发生异常/continue/django.wsgi' ;.   [Wed Feb 18 14:28:28.274038 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] Traceback(最近一次调用最后一次):   [Wed Feb 18 14:28:28.274060 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] File" /var/www/continue/django.wsgi" ;, line 18,在   [Wed Feb 18 14:28:28.274137 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036]来自django.core.wsgi import get_wsgi_application   [Wed Feb 18 14:28:28.274152 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] File" / var / www / continue / env-continue / lib / python2。 7 / site-packages / django / core / wsgi.py",第2行,in   [Wed Feb 18 14:28:28.274174 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036]来自django.core.handlers.wsgi import WSGIHandler   [Wed Feb 18 14:28:28.274186 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] File" / var / www / continue / env-continue / lib / python2。 7 / site-packages / django / core / handlers / wsgi.py",第11行,in   [Wed Feb 18 14:28:28.274211 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036]来自django import http   [Wed Feb 18 14:28:28.274229 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] File" / var / www / continue / env-continue / lib / python2。 7 / site-packages / django / http / init .py",第4行,在   [Wed Feb 18 14:28:28.274253 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036]来自django.http.response import(HttpResponse,StreamingHttpResponse,   [Wed Feb 18 14:28:28.274279 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] File" / var / www / continue / env-continue / lib / python2。 7 / site-packages / django / http / response.py",第13行,in   [Wed Feb 18 14:28:28.274298 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036]来自django.core.serializers.json import DjangoJSONEncoder   [Wed Feb 18 14:28:28.274310 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] File" / var / www / continue / env-continue / lib / python2。 7 / site-packages / django / core / serializers / init .py",第23行,在   [Wed Feb 18 14:28:28.274328 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036]来自django.core.serializers.base import SerializerDoesNotExist   [Wed Feb 18 14:28:28.274340 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] File" / var / www / continue / env-continue / lib / python2。 7 / site-packages / django / core / serializers / base.py",第6行,in   [Wed Feb 18 14:28:28.274357 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036]来自django.db导入模型   [Wed Feb 18 14:28:28.274368 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] File" / var / www / continue / env-continue / lib / python2。 7 / site-packages / django / db / models / init .py",第6行,in   [Wed Feb 18 14:28:28.274387 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036]来自django.db.models.query import Q,QuerySet,Prefetch#NOQA   [Wed Feb 18 14:28:28.274404 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] File" / var / www / continue / env-continue / lib / python2。 7 / site-packages / django / db / models / query.py",第13行,in   [Wed Feb 18 14:28:28.274435 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036]来自django.db.models.fields import AutoField,Empty   [Wed Feb 18 14:28:28.274454 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] File" / var / www / continue / env-continue / lib / python2。 7 / site-packages / django / db / models / fields / init .py",第15行,in   [Wed Feb 18 14:28:28.274489 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036]来自django.db.models.lookups import default_lookups,RegisterLookupMixin   [Wed Feb 18 14:28:28.274505 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] File" / var / www / continue / env-continue / lib / python2。 7 / site-packages / django / db / models / lookups.py",第6行,in   [Wed Feb 18 14:28:28.274525 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036]来自django.utils import timezone   [Wed Feb 18 14:28:28.274536 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] File" / var / www / continue / env-continue / lib / python2。 7 / site-packages / django / utils / timezone.py",第13行,in   [Wed Feb 18 14:28:28.274554 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] import pytz   [Wed Feb 18 14:28:28.274565 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] File" / var / www / continue / env-continue / lib / python2。 7 / site-packages / pytz / init .py",第29行,in   [Wed Feb 18 14:28:28.274583,2015] [:错误] [pid 28781:tid 140719897437952] [客户端180.76.4.231:59036]来自pkg_resources import resource_stream   [Wed Feb 18 14:28:28.274594 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] File" / var / www / continue / env-continue / lib / python2。 7 / site-packages / pkg_resources.py",第2829行,in   [Wed Feb 18 14:28:28.274612 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] working_set = WorkingSet._build_master()   [Wed Feb 18 14:28:28.274622 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] File" / var / www / continue / env-continue / lib / python2。 7 / site-packages / pkg_resources.py",第440行,在_build_master中   [Wed Feb 18 14:28:28.274639 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] ws = cls()   [Wed Feb 18 14:28:28.274656 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] File" / var / www / continue / env-continue / lib / python2。 7 / site-packages / pkg_resources.py",第433行, init   [Wed Feb 18 14:28:28.274674 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] self.add_entry(entry)   [Wed Feb 18 14:28:28.274685 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] File" / var / www / continue / env-continue / lib / python2。 7 / site-packages / pkg_resources.py",第489行,在add_entry中   [Wed Feb 18 14:28:28.274701 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] for find in find_distributions(entry,True):   [Wed Feb 18 14:28:28.274712 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] File" / var / www / continue / env-continue / lib / python2。 7 / site-packages / pkg_resources.py",第1817行,在find_distributions中   [Wed Feb 18 14:28:28.274728 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] importer = get_importer(path_item)   [Wed Feb 18 14:28:28.274739 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] File" /usr/lib/python2.7/pkgutil.py" ,第384行,在get_importer中   [Wed Feb 18 14:28:28.274756 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] importer = path_hook(path_item)   [Wed Feb 18 14:28:28.274775 2015] [:error] [pid 28781:tid 140719897437952] [client 180.76.4.231:59036] TypeError:必须是字符串,而不是元组

我想知道出了什么问题?

0 个答案:

没有答案