2010-05-25 249 views
0

当我运行开发服务器,它工作得很好,即使是空的项目在mod_wsgi的乳宁我没有问题,但是当我希望把我自己的项目中,我得到一个内部服务器错误在我的Apache配置(500)内部服务器错误

我把

WSGIScriptAlias /codevents C:/django/apache/CODEvents.wsgi 

<Directory "C:/django/apache"> 
Order allow,deny 
Allow from all 
</Directory> 

Alias /codevents/media C:/django/projects/CODEvents/html 

<Directory "C:/django/projects/CODEvents/html"> 
Order allow,deny 
Allow from all 
</Directory> 

在CODEvents.wsgi

import os, sys 
sys.path.append('C:\\Python26\\Lib\\site-packages\\django') 
sys.path.append('C:\\django\\projects') 
sys.path.append('C:\\django\\apps') 
sys.path.append('C:\\django\\projects\\CODEvents') 


os.environ['DJANGO_SETTINGS_MODULE'] = 'CODEvents.settings' 


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

,在我的error_log它说:

[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1] mod_wsgi (pid=1848): Exception occurred processing WSGI script 'C:/django/apache/CODEvents.wsgi'. 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1] Traceback (most recent call last): 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1] File "C:\\Python26\\lib\\site-packages\\django\\core\\handlers\\wsgi.py", line 241, in __call__ 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1]  response = self.get_response(request) 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1] File "C:\\Python26\\lib\\site-packages\\django\\core\\handlers\\base.py", line 142, in get_response 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1]  return self.handle_uncaught_exception(request, resolver, exc_info) 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1] File "C:\\Python26\\lib\\site-packages\\django\\core\\handlers\\base.py", line 166, in handle_uncaught_exception 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1]  return debug.technical_500_response(request, *exc_info) 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1] File "C:\\Python26\\lib\\site-packages\\django\\views\\debug.py", line 58, in technical_500_response 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1]  html = reporter.get_traceback_html() 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1] File "C:\\Python26\\lib\\site-packages\\django\\views\\debug.py", line 137, in get_traceback_html 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1]  return t.render(c) 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1] File "C:\\Python26\\lib\\site-packages\\django\\template\\__init__.py", line 173, in render 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1]  return self._render(context) 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1] File "C:\\Python26\\lib\\site-packages\\django\\template\\__init__.py", line 167, in _render 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1]  return self.nodelist.render(context) 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1] File "C:\\Python26\\lib\\site-packages\\django\\template\\__init__.py", line 796, in render 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1]  bits.append(self.render_node(node, context)) 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1] File "C:\\Python26\\lib\\site-packages\\django\\template\\debug.py", line 72, in render_node 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1]  result = node.render(context) 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1] File "C:\\Python26\\lib\\site-packages\\django\\template\\debug.py", line 89, in render 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1]  output = self.filter_expression.resolve(context) 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1] File "C:\\Python26\\lib\\site-packages\\django\\template\\__init__.py", line 579, in resolve 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1]  new_obj = func(obj, *arg_vals) 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1] File "C:\\Python26\\lib\\site-packages\\django\\template\\defaultfilters.py", line 693, in date 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1]  return format(value, arg) 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1] File "C:\\Python26\\lib\\site-packages\\django\\utils\\dateformat.py", line 281, in format 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1]  return df.format(format_string) 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1] File "C:\\Python26\\lib\\site-packages\\django\\utils\\dateformat.py", line 30, in format 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1]  pieces.append(force_unicode(getattr(self, piece)())) 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1] File "C:\\Python26\\lib\\site-packages\\django\\utils\\dateformat.py", line 187, in r 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1]  return self.format('D, j M Y H:i:s O') 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1] File "C:\\Python26\\lib\\site-packages\\django\\utils\\dateformat.py", line 30, in format 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1]  pieces.append(force_unicode(getattr(self, piece)())) 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1] File "C:\\Python26\\lib\\site-packages\\django\\utils\\encoding.py", line 66, in force_unicode 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1]  s = unicode(s) 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1] File "C:\\Python26\\lib\\site-packages\\django\\utils\\functional.py", line 206, in __unicode_cast 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1]  return self.__func(*self.__args, **self.__kw) 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1] File "C:\\Python26\\lib\\site-packages\\django\\utils\\translation\\__init__.py", line 55, in ugettext 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1]  return real_ugettext(message) 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1] File "C:\\Python26\\lib\\site-packages\\django\\utils\\functional.py", line 55, in _curried 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1]  return _curried_func(*(args+moreargs), **dict(kwargs, **morekwargs)) 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1] File "C:\\Python26\\lib\\site-packages\\django\\utils\\translation\\__init__.py", line 36, in delayed_loader 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1]  return getattr(trans, real_name)(*args, **kwargs) 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1] File "C:\\Python26\\lib\\site-packages\\django\\utils\\translation\\trans_real.py", line 276, in ugettext 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1]  return do_translate(message, 'ugettext') 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1] File "C:\\Python26\\lib\\site-packages\\django\\utils\\translation\\trans_real.py", line 266, in do_translate 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1]  _default = translation(settings.LANGUAGE_CODE) 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1] File "C:\\Python26\\lib\\site-packages\\django\\utils\\translation\\trans_real.py", line 176, in translation 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1]  default_translation = _fetch(settings.LANGUAGE_CODE) 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1] File "C:\\Python26\\lib\\site-packages\\django\\utils\\translation\\trans_real.py", line 159, in _fetch 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1]  app = import_module(appname) 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1] File "C:\\Python26\\lib\\site-packages\\django\\utils\\importlib.py", line 35, in import_module 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1]  __import__(name) 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1] File "C:\\Python26\\lib\\site-packages\\django\\contrib\\admin\\__init__.py", line 1, in <module> 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1]  from django.contrib.admin.helpers import ACTION_CHECKBOX_NAME 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1] File "C:\\Python26\\lib\\site-packages\\django\\contrib\\admin\\helpers.py", line 1, in <module> 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1]  from django import forms 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1] File "C:\\Python26\\lib\\site-packages\\django\\forms\\__init__.py", line 17, in <module> 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1]  from models import * 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1] File "C:\\Python26\\lib\\site-packages\\django\\forms\\models.py", line 6, in <module> 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1]  from django.db import connections 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1] File "C:\\Python26\\lib\\site-packages\\django\\db\\__init__.py", line 75, in <module> 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1]  connection = connections[DEFAULT_DB_ALIAS] 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1] File "C:\\Python26\\lib\\site-packages\\django\\db\\utils.py", line 91, in __getitem__ 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1]  backend = load_backend(db['ENGINE']) 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1] File "C:\\Python26\\lib\\site-packages\\django\\db\\utils.py", line 49, in load_backend 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1]  raise ImproperlyConfigured(error_msg) 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1] TemplateSyntaxError: Caught ImproperlyConfigured while rendering: 'django.db.backends.postgresql_psycopg2' isn't an available database backend. 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1] Try using django.db.backends.XXX, where XXX is one of: 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1]  'dummy', 'mysql', 'oracle', 'postgresql', 'postgresql_psycopg2', 'sqlite3' 
[Mon May 24 23:31:39 2010] [error] [client 127.0.0.1] Error was: cannot import name utils 

请帮助我!

回答

0

那么实际上我的问题是pyscopg2的Windows版本,我用的是最新版本(2.2.1),我只是降级到2.0.14,它是活的!

+0

我也有这个问题...我也降级pyscopg2到[v2.0.14(HTTP:// WWW。 stickpeople.com/projects/python/win-psycopg/index.2.0.14.html),它的工作。尽管上面的网站表示psycopg2的版本是针对PostgreSQL v8.4.3构建的,而且我正在运行9.0! – Anentropic 2010-11-18 14:04:15

1

错误认为,对于PostgreSQL客户端Python模块找不到或导入失败。你在哪里安装它?这些文件是否可以通过Apache服务访问,它作为一个独立的用户来运行?

+0

我安装在C:\ Archivos德programa \的PostgreSQL \ 8.4,我怎么能知道,如果可以访问文件通过Apache就窗口? – sacabuche 2010-05-25 03:22:57

+0

和psycopg2在C:\ Python26 \ LIB \站点包\ psycopg2 – sacabuche 2010-05-25 03:29:54

+0

感谢你指导我的答案 – sacabuche 2010-05-25 04:07:43