Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting python MySQLdb to run on Ubuntu

I created a virtualbox with a fresh install of ubuntu 9.10.

I am trying to get MySQLdb to run on python but I'm failing at the import MySQLdb

I first tried sudo easy_install MySQL_python-1.2.3c1-py2.6-linux-i686.egg and then sudo apt-get install python-mysqldb.

Both apparently installed ok, but gave me the following error message when in python I have the import line:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.6/dist-packages/MySQL_python-1.2.3c1-py2.6-linux-i686.egg/MySQLdb/__init__.py", line 19, in <module>

File "/usr/local/lib/python2.6/dist-packages/MySQL_python-1.2.3c1-py2.6-linux-i686.egg/_mysql.py", line 7, in <module>
File "/usr/local/lib/python2.6/dist-packages/MySQL_python-1.2.3c1-py2.6-linux-i686.egg/_mysql.py", line 6, in __bootstrap__
ImportError: libmysqlclient_r.so.15: cannot open shared object file: No such file or directory

I have already installed MySQL and it is running, if that matters at all. I tried following this, but failed in step 2

like image 674
greye Avatar asked Feb 04 '10 08:02

greye


People also ask

Does MySQLdb work with python3?

MySQLdb module, a popular interface with MySQL is not compatible with Python 3.

What is Python MySQLdb package?

MySQLdb is an interface for connecting to a MySQL database server from Python. It implements the Python Database API v2. 0 and is built on top of the MySQL C API. Packages to Install. mysql-connector-python mysql-python.


1 Answers

Your MySQLdb egg installation looks like it is not working properly. You should go into /usr/local/lib/python2.6/dist-packages and remove it.

The Ubuntu python-mysqldb package should work fine. Unless you have a good reason, you should stick to your distribution's package manager when installing new software.

like image 108
Cristian Avatar answered Oct 13 '22 01:10

Cristian