Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ubuntu mysqldb not installed properly

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
like image 679
locoboy Avatar asked Mar 04 '12 02:03

locoboy


People also ask

How to fix mysqldb module is not available in Python?

The error message indicates that there is no module named MySQLdb. It means, Python needs a module to interface with MySQL database and that modules does not seems to be present in the system. All you need to do is, just install MySQL-Pythonmodule and the script should work without any problem. You can use pipto install any Python module.

How to fix MySQL_config is missing on Ubuntu?

mysqlclient has a dependency on the mysql client & dev packages being installed. In order to fix this on ubuntu, you have to use apt-get to install a couple of mysql packages. In your case, it looks like the missing mysql_config might be missing on your system.

What is mysqldb in Python?

Furthermore to be more specific, it is an interface provided for Python so that the connection to MySQL Database can be achieved. The support or the interface is provided by installing a package named ‘python-mysqldb’.

What version of Python does MySQL client run on?

It's a Linux Ubuntu 18.04 server with Plesk. Python version 3.8. Show activity on this post. mysqlclient has a dependency on the mysql client & dev packages being installed.


1 Answers

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.

like image 92
Tyrone Wilson Avatar answered Sep 18 '22 03:09

Tyrone Wilson