0

I have installed mysql in my virtual environment using this command and it has installed successfully..

sudo apt-get install libmysqlclient-dev
sudo pip install MySQL-python

Now in my settings.py I have done this..

DATABASES = {
'default': {
    'ENGINE': 'django.db.backends.mysql',
    'NAME': os.path.join(BASE_DIR, 'db_hotelnepal'),
}
}

But when I run server it throws error saying ""Error loading MySQLdb module: %s" % e) django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb""...

Whats the prob and how can I fix ?

Barmar
  • 741,623
  • 53
  • 500
  • 612
gamer
  • 5,673
  • 13
  • 58
  • 91
  • check `pip freeze` and make sure `MySQL-python==1.2.5` is there or not ? – Raja Simon Sep 11 '14 at 04:41
  • Please read the second answer here http://stackoverflow.com/questions/19189813/setting-django-up-to-use-mysql/ – Ritesh Sep 11 '14 at 04:42
  • Now it throws the error saying ""django.db.utils.OperationalError: (2002, "Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)")"" – gamer Sep 11 '14 at 07:45

1 Answers1

0

MySQL-python is not compatible with python 3, and it gives this error. You didn't mention the python version you are using, but I have only seen this when using python 3 and MySQL, so I will make that assumption. I use MySQL-for-Python-3 which can be found here: MySQL-for-Python-3. It is compatible with python 2.7-3.3, haven't had a project with MySQL and python 3.4 to try it yet.

I install by running pip install https://github.com/davispuh/MySQL-for-Python-3/archive/1.0.tar.gz

awwester
  • 9,623
  • 13
  • 45
  • 72