python - Django 500 Internal Server Error - ImproperlyConfigured: Error loading MySQLdb module: -


im new using mysql in general , database django. have followed number of different tutorials , documentation keep getting 500 internal server error when deploy production server. works fine on development machine.

what missing? there setting should change or step missed?

thanks

the error logs

[mon aug 18 19:23:10 2014] [error] [client 134.226.38.233]     return getattr(connections[default_db_alias], item) [mon aug 18 19:23:10 2014] [error] [client 134.226.38.233]   file "/var/www/bias_experiment/lib/python2.7/site-packages/django/db/utils.py", line 198, in __getitem__ [mon aug 18 19:23:10 2014] [error] [client 134.226.38.233]     backend = load_backend(db['engine']) [mon aug 18 19:23:10 2014] [error] [client 134.226.38.233]   file "/var/www/bias_experiment/lib/python2.7/site-packages/django/db/utils.py", line 113, in load_backend [mon aug 18 19:23:10 2014] [error] [client 134.226.38.233]     return import_module('%s.base' % backend_name) [mon aug 18 19:23:10 2014] [error] [client 134.226.38.233]   file "/var/www/bias_experiment/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module [mon aug 18 19:23:10 2014] [error] [client 134.226.38.233]     __import__(name) [mon aug 18 19:23:10 2014] [error] [client 134.226.38.233]   file "/var/www/bias_experiment/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 17, in <module> [mon aug 18 19:23:10 2014] [error] [client 134.226.38.233]     raise improperlyconfigured("error loading mysqldb module: %s" % e) [mon aug 18 19:23:10 2014] [error] [client 134.226.38.233] improperlyconfigured: error loading mysqldb module: mysqldb version (1, 2, 5, 'final', 1), _mysql version (1, 2, 3, 'final', 0) 

my setup

  • ubuntu vm running 12.04.5 lts
  • apache/2.2.22 (ubuntu)
  • python 2.7.3
  • virtualenv==1.7.1.2
  • django==1.6
  • mysql-python==1.2.3
  • mysql ver 14.14 distrib 5.5.38, debian-linux-gnu (x86_64) using readline 6.2

my settings.py

databases = {     'default': {          'engine': 'django.db.backends.mysql',          'name': 'django_db',                                                'user': 'root',         'password': 'my_password',         'host': '127.0.0.1',         'port': '',      } } 

i have created database on production environment

create database django_db; query ok, 1 row affected (0.01 sec)  mysql> 

i ran syncdb

(bias_experiment)macintosh-2:src user$ python manage.py syncdb creating tables ... creating table django_admin_log .... 

this line:

improperlyconfigured: error loading mysqldb module: mysqldb version (1, 2, 5, 'final', 1), _mysql version (1, 2, 3, 'final', 0)  

indicates might have version mismatch between mysqldb , mysql. sounds looking in , reinstalling dependent libraries resolved issue.

to describe issue in further detail:

in case apt-get installing mysql-python==1.2.3. latest version mysql-python==1.2.5. apt-get not finding it, removing mysql-python==1.2.3 using:

sudo apt-get remove --purge python-mysqldb 

and reinstall via pip

sudo pip install mysql-python 

(note package names different)


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -