Improperly Configured MySQL DB Module-Exception – Django – Windows 7

I had this error after I installed Django, created a project, modified the settings.py to use the MySQL database and while I tried to create the necessary tables in the MySQL by running the following command.

 python manage.py syncdb 

I got this exception

 .......

backend = load_backend(db['ENGINE'])
  File "c:\Python27\lib\site-packages\django\db\utils.py", line 33, in load_backend
    return import_module('.base', backend_name)
  File "c:\Python27\lib\site-packages\django\utils\importlib.py", line 35, in import_module
    __import__(name)
  File "c:\Python27\lib\site-packages\django\db\backends\mysql\base.py", line 14, in 
    raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb 

I was using Python 2.7 , so the solution was to use the MySQL Python connector. I downloaded it from here

After , I Installed the MySQL Python Connector, I created the MySQL database,(make sure you commit it) This seemed to work fine.

 $ python manage.py syncdb
Creating tables ...
Creating table auth_permission
Creating table auth_group_permissions
Creating table auth_group
Creating table auth_user_user_permissions
Creating table auth_user_groups
Creating table auth_user
Creating table auth_message
Creating table django_content_type
Creating table django_session
Creating table django_site

You just installed Django's auth system, which means you don't have any superusers defined.
Would you like to create one now? (yes/no): yes
Username (Leave blank to use 'test'):
E-mail address: test@gmail.com
Password:
Password (again):
Superuser created successfully.
Installing custom SQL ...
Installing indexes ...
No fixtures found. 

Hopefully this helps.

Leave a comment