Saturday, November 16, 2013

django mysql exception

After facing some compatibility issues of my system, I upgraded my debian squeeze to wheezy. I used Python2.6 and the latest distro upgrade gave 2.7 version, which cause me to fix so many dependencies of my django project. This is one issue I faced.

    new_class.add_to_class('_meta', Options(meta, **kwargs))
  File "/home/jgeek/playground/project-wl/local/lib/python2.7/site-packages/django/db/models/base.py", line 264, in add_to_class
    value.contribute_to_class(cls, name)
  File "/home/jgeek/playground/project-wl/local/lib/python2.7/site-packages/django/db/models/options.py", line 124, in contribute_to_class
    self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
  File "/home/jgeek/playground/project-wl/local/lib/python2.7/site-packages/django/db/__init__.py", line 34, in __getattr__
    return getattr(connections[DEFAULT_DB_ALIAS], item)
  File "/home/jgeek/playground/project-wl/local/lib/python2.7/site-packages/django/db/utils.py", line 198, in __getitem__
    backend = load_backend(db['ENGINE'])
  File "/home/jgeek/playground/project-wl/local/lib/python2.7/site-packages/django/db/utils.py", line 113, in load_backend
    return import_module('%s.base' % backend_name)
  File "/home/jgeek/playground/project-wl/local/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module
    __import__(name)
  File "/home/jgeek/playground/project-wl/local/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 17, in <module>
    raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb


Solution:

install "python-mysqldb" "libmysqlclient-dev" from distro repositories.
install "django"
install "mysql-python" from pip.
          $ pip install mysql-python

run "python manage.py syncdb" again.

No comments:

Post a Comment