I am asking the following question here, because it involves developer tools.
I have upgraded my Ubuntu 10.04 LTS workstation to 12.04 LTS (32-bit). Today I went to try a Django web application that has been working without errors. It is running on Apache.
The application no longer works and returns an error. I have been working through a series of errors all located in /var/log/apache2/error.log.
The first error involved UCS2 and UCS4 (lines trimmed for readability).
ImportError: /usr/local/lib/python2.7/lib-dynload/_io.so:
undefined symbol: PyUnicodeUCS2_FromObject
mod_wsgi (pid=9246): Target WSGI script
'/usr/local/www/wsgi-scripts/wsgi_amr_handler.py'
cannot be loaded as Python module.
That was cleared by rebuilding and re-installing the latest version of mod_wsgi.
The current error involves mysqldb not being a valid backend. Here is the error (timestamps removed for clarity):
backend = load_backend(db['ENGINE'])
File "/usr/local/lib/python2.7/site-packages/django/db/utils.py", line 51,
in load_backend
raise ImproperlyConfigured(error_msg)
ImproperlyConfigured: 'mysql' isn't an available database backend.
Try using django.db.backends.mysql instead.
Error was: No module named mysql.base
Is this a configuration problem in the Django application’s settings.py or something else?
Is there an installation order for Python 2.7, mod_wsgi, Django, and mysqldb, and could that be the problem?
Here is my current (after receiving comments) settings.py
DATABASES = {
'default': {
'ENGINE': ' django.db.backends.mysql',
'NAME': 'server', # Or path to database file if using sqlite3.
'USER': 'ox', # Not used with sqlite3.
'PASSWORD': 'xxxx', # Not used with sqlite3.
'HOST': '',
'PORT': '',
}
}
Here are the errors:
ImproperlyConfigured: ' django.db.backends.mysql' isn't an available database backend.
Try using django.db.backends.XXX, where XXX is one of:
'dummy', 'mysql', 'oracle', 'postgresql_psycopg2', 'sqlite3'
Error was: No module named django.db.backends.mysql.base
You apparently upgraded you Django installation as well. Recent Django versions need the full name of the backend module. The way you specify databases was changed in version 1.2 and you’ll need to follow the upgrade notes to update your Django project codebase.
For MySQL the correct backend is now
django.db.backends.mysql; opensettings.pyand update yourDATABASESentry.