PETR KOUT - ENGINEERING AND PHYSICS

MY PERSONAL SITE AND BLOG ABOUT SOFTWARE AND HARDWARE ENGINEERING, AND PHYSICS

A solution to the /python2.7/site-packages/_mysql.so: undefined symbol: mysql_kill error

By Petr Kout, July 25, 2014


A solution to the /python2.7/site-packages/_mysql.so: undefined symbol: mysql_kill error

I use Django with MySQL and I this error bothers me almost every time I start a new project with a fresh new installation of Django and relevant Python packages. I use virtualenv to isolate my Python environment for each project. The problem that’s causing this error is that the Python MySQL libraries that are installed via aptitude (I am on Ubuntu) are too old and need to be recompiled.

To do that, I first remove the default installation:


sudo apt-get uninstall mysql-python

and then I use pip to download and compile the latest package. Before the compilation starts, we first need to install some dependencies:

sudo apt-get install package python-dev build-essential libmysqlclient-dev python-pip

Now we can install the up-to-date Python MySQL libraries:

pip install --upgrade python-mysql

This should solve the problem.