5

I'm running the following commands and get the following error:

root# sudo python manage.py syncdb
Traceback (most recent call last):
  File "manage.py", line 14, in <module>
    execute_manager(settings)
  File "/usr/lib/pymodules/python2.6/django/core/management/__init__.py", line 438, in execute_manager
    utility.execute()
  File "/usr/lib/pymodules/python2.6/django/core/management/__init__.py", line 379, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/lib/pymodules/python2.6/django/core/management/__init__.py", line 261, in fetch_command
    klass = load_command_class(app_name, subcommand)
  File "/usr/lib/pymodules/python2.6/django/core/management/__init__.py", line 67, in load_command_class
    module = import_module('%s.management.commands.%s' % (app_name, name))
  File "/usr/lib/pymodules/python2.6/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/usr/lib/pymodules/python2.6/django/core/management/commands/syncdb.py", line 7, in <module>
    from django.core.management.sql import custom_sql_for_model, emit_post_sync_signal
  File "/usr/lib/pymodules/python2.6/django/core/management/sql.py", line 5, in <module>
    from django.contrib.contenttypes import generic
  File "/usr/lib/pymodules/python2.6/django/contrib/contenttypes/generic.py", line 6, in <module>
    from django.db import connection
  File "/usr/lib/pymodules/python2.6/django/db/__init__.py", line 77, in <module>
    connection = connections[DEFAULT_DB_ALIAS]
  File "/usr/lib/pymodules/python2.6/django/db/utils.py", line 91, in __getitem__
    backend = load_backend(db['ENGINE'])
  File "/usr/lib/pymodules/python2.6/django/db/utils.py", line 32, in load_backend
    return import_module('.base', backend_name)
  File "/usr/lib/pymodules/python2.6/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/usr/lib/pymodules/python2.6/django/db/backends/mysql/base.py", line 14, in <module>
    raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: libmysqlclient_r.so.16: cannot open shared object file: No such file or directory

I have a feeling that mysqldb isn't configured properly with django, I was wondering if i'm missing anything. i ran the following commands right before it:

# apt-get install python-django
# apt-get install python-mysqldb
locoboy
  • 38,002
  • 70
  • 184
  • 260
  • It's hard to tell what's going on without know more about the server, but I would try to do the installs with sudo. this is a pretty similar post to http://stackoverflow.com/questions/7459766/installing-mysql-python – David S Mar 04 '12 at 04:12
  • Paste the output of `apt-get install python-mysqldb` – Burhan Khalid Mar 04 '12 at 06:02
  • `sudo apt-get install python-mysqldb Reading package lists... Done Building dependency tree Reading state information... Done python-mysqldb is already the newest version. 0 upgraded, 0 newly installed, 0 to remove and 73 not upgraded.` – locoboy Mar 04 '12 at 07:31

1 Answers1

11

I had this same issue where my virtualenv was broken and could no longer run django when I upgraded to ubuntu 12.04.

I simply ran (while my ve was active)

pip uninstall MySQL-python

and then re-installed it with

pip install MySQL-python

worked fine again after that.

Tyrone Wilson
  • 4,328
  • 2
  • 31
  • 35
  • 2
    P.S. Note that I had already made sure my dependencies for the pip install were installed. If you come across an error about 'gcc' something or other (cannot compile some c dependency) then run `sudo apt-get build-dep python-mysqldb` – Tyrone Wilson May 04 '12 at 14:46
  • I had the exact same issue after I upgraded to 12.04, and this re-install trick fixed it. Thanks! – Steve Jul 28 '12 at 11:07