#14013 closed (invalid)
'django.db.backends.postgresql_psycopg2' isn't an available database backend. (?!?!?)
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | dev |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
I'm currently teaching myself Django.
So, I successfully installed
Operating System: Windows XP SP3 Python: Version 2.7 Django: Revision 13446 Database: PostgreSQL 8.4 Postgre Driver: psycopg2.2.2 LAMP: XAMPP (Apache Friends Edition) Python Interface: mod_wsgi
I configured a virtual host for my Django project.
For the most part, everything is "playing well together".
However, when I try to use Django with the Apache server, I get an error which seems similar to "invalid" ticket #12730... except for I don't have deseb.
This is my errorlog:
[Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] mod_wsgi (pid=2968): Exception occurred processing WSGI script 'D:/education/python/FirstProject/mysite/django.wsgi'. [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] Traceback (most recent call last): [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] File "C:\\devtool\\Python27\\lib\\site-packages\\django\\core\\handlers\\wsgi.py", line 241, in __call__ [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] response = self.get_response(request) [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] File "C:\\devtool\\Python27\\lib\\site-packages\\django\\core\\handlers\\base.py", line 141, in get_response [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] return self.handle_uncaught_exception(request, resolver, sys.exc_info()) [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] File "C:\\devtool\\Python27\\lib\\site-packages\\django\\core\\handlers\\base.py", line 165, in handle_uncaught_exception [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] return debug.technical_500_response(request, *exc_info) [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] File "C:\\devtool\\Python27\\lib\\site-packages\\django\\views\\debug.py", line 58, in technical_500_response [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] html = reporter.get_traceback_html() [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] File "C:\\devtool\\Python27\\lib\\site-packages\\django\\views\\debug.py", line 137, in get_traceback_html [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] return t.render(c) [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] File "C:\\devtool\\Python27\\lib\\site-packages\\django\\template\\__init__.py", line 173, in render [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] return self._render(context) [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] File "C:\\devtool\\Python27\\lib\\site-packages\\django\\template\\__init__.py", line 167, in _render [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] return self.nodelist.render(context) [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] File "C:\\devtool\\Python27\\lib\\site-packages\\django\\template\\__init__.py", line 796, in render [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] bits.append(self.render_node(node, context)) [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] File "C:\\devtool\\Python27\\lib\\site-packages\\django\\template\\debug.py", line 72, in render_node [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] result = node.render(context) [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] File "C:\\devtool\\Python27\\lib\\site-packages\\django\\template\\debug.py", line 89, in render [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] output = self.filter_expression.resolve(context) [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] File "C:\\devtool\\Python27\\lib\\site-packages\\django\\template\\__init__.py", line 579, in resolve [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] new_obj = func(obj, *arg_vals) [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] File "C:\\devtool\\Python27\\lib\\site-packages\\django\\template\\defaultfilters.py", line 693, in date [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] return format(value, arg) [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] File "C:\\devtool\\Python27\\lib\\site-packages\\django\\utils\\dateformat.py", line 281, in format [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] return df.format(format_string) [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] File "C:\\devtool\\Python27\\lib\\site-packages\\django\\utils\\dateformat.py", line 30, in format [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] pieces.append(force_unicode(getattr(self, piece)())) [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] File "C:\\devtool\\Python27\\lib\\site-packages\\django\\utils\\dateformat.py", line 187, in r [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] return self.format('D, j M Y H:i:s O') [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] File "C:\\devtool\\Python27\\lib\\site-packages\\django\\utils\\dateformat.py", line 30, in format [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] pieces.append(force_unicode(getattr(self, piece)())) [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] File "C:\\devtool\\Python27\\lib\\site-packages\\django\\utils\\encoding.py", line 66, in force_unicode [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] s = unicode(s) [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] File "C:\\devtool\\Python27\\lib\\site-packages\\django\\utils\\functional.py", line 206, in __unicode_cast [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] return self.__func(*self.__args, **self.__kw) [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] File "C:\\devtool\\Python27\\lib\\site-packages\\django\\utils\\translation\\__init__.py", line 55, in ugettext [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] return real_ugettext(message) [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] File "C:\\devtool\\Python27\\lib\\site-packages\\django\\utils\\functional.py", line 55, in _curried [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] return _curried_func(*(args+moreargs), **dict(kwargs, **morekwargs)) [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] File "C:\\devtool\\Python27\\lib\\site-packages\\django\\utils\\translation\\__init__.py", line 36, in delayed_loader [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] return getattr(trans, real_name)(*args, **kwargs) [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] File "C:\\devtool\\Python27\\lib\\site-packages\\django\\utils\\translation\\trans_real.py", line 276, in ugettext [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] return do_translate(message, 'ugettext') [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] File "C:\\devtool\\Python27\\lib\\site-packages\\django\\utils\\translation\\trans_real.py", line 266, in do_translate [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] _default = translation(settings.LANGUAGE_CODE) [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] File "C:\\devtool\\Python27\\lib\\site-packages\\django\\utils\\translation\\trans_real.py", line 176, in translation [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] default_translation = _fetch(settings.LANGUAGE_CODE) [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] File "C:\\devtool\\Python27\\lib\\site-packages\\django\\utils\\translation\\trans_real.py", line 159, in _fetch [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] app = import_module(appname) [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] File "C:\\devtool\\Python27\\lib\\site-packages\\django\\utils\\importlib.py", line 35, in import_module [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] __import__(name) [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] File "C:\\devtool\\Python27\\lib\\site-packages\\django\\contrib\\admin\\__init__.py", line 1, in <module> [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] from django.contrib.admin.helpers import ACTION_CHECKBOX_NAME [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] File "C:\\devtool\\Python27\\lib\\site-packages\\django\\contrib\\admin\\helpers.py", line 1, in <module> [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] from django import forms [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] File "C:\\devtool\\Python27\\lib\\site-packages\\django\\forms\\__init__.py", line 17, in <module> [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] from models import * [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] File "C:\\devtool\\Python27\\lib\\site-packages\\django\\forms\\models.py", line 6, in <module> [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] from django.db import connections [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] File "C:\\devtool\\Python27\\lib\\site-packages\\django\\db\\__init__.py", line 75, in <module> [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] connection = connections[DEFAULT_DB_ALIAS] [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] File "C:\\devtool\\Python27\\lib\\site-packages\\django\\db\\utils.py", line 91, in __getitem__ [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] backend = load_backend(db['ENGINE']) [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] File "C:\\devtool\\Python27\\lib\\site-packages\\django\\db\\utils.py", line 49, in load_backend [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] raise ImproperlyConfigured(error_msg) [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] TemplateSyntaxError: Caught ImproperlyConfigured while rendering: 'django.db.backends.postgresql_psycopg2' isn't an available database backend. [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] Try using django.db.backends.XXX, where XXX is one of: [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] 'dummy', 'mysql', 'oracle', 'postgresql', 'postgresql_psycopg2', 'sqlite3' [Tue Jul 27 21:14:49 2010] [error] [client 127.0.0.1] Error was: cannot import name utils
I saw a suggestion (elsewhere on the web) that I might fix this if I downgrade psycopg2 to 2.0.14, but to even test this fix, I will also need to downgrade Python to 2.6 ... but so far as I can tell, the problem isn't with either of those since they are both working fine together with python manage.py runserver
Moreover, I have confirmed the problem isn't with my Apache configuration, since everything works fine if I replace Postgre with SQLite3
Change History (9)
comment:1 by , 14 years ago
Description: | modified (diff) |
---|
comment:2 by , 14 years ago
Sorry about that.
For 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.
(of course, I also had to modify my environmental variables and purge the *.pyc files)
comment:3 by , 14 years ago
psycopg2-2.2.2\psycopg2-2.2.2\setup.py
def finalize_win32(self):
...
self.libraries.append("crypt32") <--- here is the promlem IMHO
comment:4 by , 14 years ago
I've solved this problem using MinGW compilator for psycopg2-2.2.2. Anything works OK!
comment:5 by , 14 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
comment:6 by , 14 years ago
I have also confirmed that the following combination works on Windows XP, SP3, x86 CPU:
psycopg2 2.0.14
apache 2.2.17
python 2.6.5 (installed from pythonxy, v2.6.5.6)
mod_wsgi-win32-ap22py26-3.3.so
postgresql 9.0.2-1
django-1.2.4
hope this information will help people developing on Windows.... (it took me 24 hours or so to finally get the setup to work...)
comment:7 by , 14 years ago
I now have django working on Windows 7...
psycopg2 2.0.14 apache 2.2.17 python 2.6.6 mod_wsgi-win32-ap22py26-3.3.so postgresql 9.0.3-1 django-1.2.5
I don't want to admit to how long this has taken me... started off days ago trying to get everything working 64 bit!
comment:8 by , 14 years ago
For reference as to likely cause of this problem, see:
http://psycopg.lighthouseapp.com/projects/62710/tickets/20
Although the description of psyocpg2 issue tracker suggests it should also occur for Python 2.6, so may not be exact same issue or users environment is somehow different.
The psycopg2 people are trialling a fix for this issue at this time. See:
https://groups.google.com/d/topic/modwsgi/_xU1U9Hrr_I/discussion
comment:9 by , 14 years ago
Thanks graham - Jason Erickson's psycopg2-2.4-beta2.win32-py2.7 build (link) is working for me.
Reformatted the description.
Next time please read the recommendations listed under Read this first section on the page you used to create the ticket. One of them read:
To include code snippets in the ticket description, surround them with curley braces (
code snippet
). Read more about formatting on the WikiFormatting page.