django、postgres 8.4、psycopg 2.2.2、python 2.7、mod_wsgi

发布于 2024-09-16 19:01:38 字数 2320 浏览 7 评论 0原文

我已经在本地 django 服务器上安装了 django/postgres 并且工作正常。我正在努力让 Apache 工作。我已经设置了 mod_wsgi 并能够得到“Hello World”,并重新启动 Apache。我已经快到了,但是当我打开 localhost/index.html 时,我收到此服务器错误:

TemplateSyntaxError: Caught ImproperlyConfigured while rendering: 
'django.db.backends.postgresql_psycopg2' isn't an available database 
backend. 
[Thu Sep 02 13:46:30 2010] [error] [client 127.0.0.1] Try using 
django.db.backends.XXX, where XXX is one of: 
[Thu Sep 02 13:46:30 2010] [error] [client 127.0.0.1]     'dummy', 
'mysql', 'oracle', 'postgresql', 'postgresql_psycopg2', 'sqlite3' 
[Thu Sep 02 13:46:30 2010] [error] [client 127.0.0.1] Error was: 
cannot import name utils 

Is it possible that mod_wsgi and the version psycopg are incompatible?有人尝试过这种类型的设置吗?

更新 1:

我降级到 2.6、mod_wsgi、psycopg2,但在 apache 日志文件中仍然出现此错误。

2010 年 9 月 3 日星期五 12:17:41] [错误] [客户端 97.80.165.181] 文件 “C:\ Python26 \ lib \ site-packages \ django \ db \ __ init __.py”, 第 77 行,于 [9 月 3 日星期五 12:17:41 2010] [错误] [客户端 97.80.165.181] 连接 = 连接 [DEFAULT_DB_ALIAS] [周五九月 03 12:17:41 2010] [错误] [客户端 97.80.165.181]文件“C:\ Python26 \ lib \ site-packages \ django \ db \ utils.py”, 第 91 行,位于 getitem [9 月 3 日星期五 12:17:41 2010] [错误] [客户端 97.80.165.181] backend = load_backend(db['ENGINE']) [9 月 3 日星期五 12:17:41 2010] [错误] [客户端 97.80.165.181]文件“C:\ Python26 \ lib \ site-packages \ django \ db \ utils.py”, 第 49 行,在 load_backend [9 月 3 日星期五 12:17:41 2010] [错误] [客户端 97.80.165.181] 引发 ImproperlyConfigured(error_msg) [周五 2010 年 9 月 3 日 12:17:41] [错误] [客户端 97.80.165.181] TemplateSyntaxError:在配置不当时捕获 渲染: 'django.db.backends.postgresql_psycopg2' 不是可用的数据库后端。 [2010 年 9 月 3 日星期五 12:17:41] [错误] [客户端 97.80.165.181] 尝试使用 django.db.backends.XXX,其中 XXX 是 其中之一:[2010 年 9 月 3 日星期五 12:17:41] [错误] [客户端 97.80.165.181]
'虚拟','mysql','oracle', 'postgresql', 'postgresql_psycopg2', 'sqlite3' [2010 年 9 月 3 日星期五 12:17:41] [错误] [客户端 97.80.165.181] 错误 是:无法导入名称实用程序

你知道它可能表示什么吗?

更新2:

原因在文件 django/db/backends/postgresql_psycopg2/base.py,版本 2.2.2,行号 9 中: from django.db import utils

但我仍然不知道如何解决这个问题。 有一个文件 django/db/utils.py,所以它应该可以工作。毕竟它适用于开发服务器。但不适用于 Apache + mod_wsgi

I've installed django/postgres on local django server and works fine. I'm trying to get Apache working. I've set up the mod_wsgi and was able to get a "Hello World", and restart Apache. I'm almost there, but when I bring up localhost/index.html I get this server error:

TemplateSyntaxError: Caught ImproperlyConfigured while rendering: 
'django.db.backends.postgresql_psycopg2' isn't an available database 
backend. 
[Thu Sep 02 13:46:30 2010] [error] [client 127.0.0.1] Try using 
django.db.backends.XXX, where XXX is one of: 
[Thu Sep 02 13:46:30 2010] [error] [client 127.0.0.1]     'dummy', 
'mysql', 'oracle', 'postgresql', 'postgresql_psycopg2', 'sqlite3' 
[Thu Sep 02 13:46:30 2010] [error] [client 127.0.0.1] Error was: 
cannot import name utils 

Is it possible that mod_wsgi and the version psycopg are incompatible? Has anyone tried this type of setup?

Update 1:

I downgraded to 2.6, mod_wsgi, psycopg2 and still get this error in apache log file.

Fri Sep 03 12:17:41 2010] [error]
[client 97.80.165.181] File
"C:\Python26\lib\site-packages\django\db\__init__.py",
line 77, in [Fri Sep 03
12:17:41 2010] [error] [client
97.80.165.181] connection = connections[DEFAULT_DB_ALIAS] [Fri Sep
03 12:17:41 2010] [error] [client
97.80.165.181] File "C:\Python26\lib\site-packages\django\db\utils.py",
line 91, in getitem [Fri Sep 03
12:17:41 2010] [error] [client
97.80.165.181] backend = load_backend(db['ENGINE']) [Fri Sep 03
12:17:41 2010] [error] [client
97.80.165.181] File "C:\Python26\lib\site-packages\django\db\utils.py",
line 49, in load_backend [Fri Sep 03
12:17:41 2010] [error] [client
97.80.165.181] raise ImproperlyConfigured(error_msg) [Fri
Sep 03 12:17:41 2010] [error] [client
97.80.165.181] TemplateSyntaxError: Caught ImproperlyConfigured while
rendering:
'django.db.backends.postgresql_psycopg2'
isn't an available database backend.
[Fri Sep 03 12:17:41 2010] [error]
[client 97.80.165.181] Try using
django.db.backends.XXX, where XXX is
one of: [Fri Sep 03 12:17:41 2010]
[error] [client 97.80.165.181]
'dummy', 'mysql', 'oracle',
'postgresql', 'postgresql_psycopg2',
'sqlite3' [Fri Sep 03 12:17:41 2010]
[error] [client 97.80.165.181] Error
was: cannot import name utils

Do you know what it might indicate?

Update 2:

The cause is in the file django/db/backends/postgresql_psycopg2/base.py, version 2.2.2, line number 9:
from django.db import utils

But I still don't know how to fix this.
There is a file django/db/utils.py, so it should work. And it works for the development server, after all. But not for Apache + mod_wsgi

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

℡Ms空城旧梦 2024-09-23 19:01:38

也许这张票可以帮助您:

或者无论它值多少钱,我都有
确认如果我降级 python
到 2.6 然后同样降级
mod_wsgi 和 psycopg2,Django 将
在 Apache 上使用 Postgres 作为
预计

Maybe this Ticket helps you:

or whatever it is worth, I have
confirmed that if I downgrade python
to 2.6 and then likewise downgrade
mod_wsgi and psycopg2, Django will
work with Postgres on Apache as
expected

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文