Error loading MySQLdb module: No module named MySQLdb

653 views Asked by At

i am getting this error when running python manage.py syncdb.

I've tried installing all the packages that were described in various posts to no avail.I desperately want a solution as i have lost too many time in this!

Thanks in advance for any help!

Edit: Also my setting for database is:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg3', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': 'db1',                      # Or path to database file if using sqlite3.
        'USER': 'root',                      # Not used with sqlite3.
        'PASSWORD': 'XYZ',                  # Not used with sqlite3.
        'HOST': 'localhost',                      # Set to empty string for localhost. Not used with sqlite3.
        'PORT': '3306',                      # Set to empty string for default. Not used with sqlite3.
    }
}

My O.S is Linux Mint 17.1 Mate.

Also do i need to install django in a virtual environment?

2

There are 2 answers

0
Vardan On

Try installing this way

apt-get install python-dev libmysqlclient-dev
pip install MySQL-python
0
Kush On

Phew!

Got it working at last!

Seems like my Django package was not compatible with libs & dependencies.I created a virtual environment and installed the latest Django package as well as its dependencies, libs etc.

That is it!