Installing MySQL for Python in Ubuntu

pythonWhilst on the grind this evening, hacking on some Python code in a newly-installed Ubuntu virtual machine, I needed to install MySQL for Python. Building the package, pre-installation, requires mysql_config — which I had some difficulty locating in the repositories. After flailing about a bit, the solution is to install the libmysqlclient-dev package.

$ sudo apt-get install libmysqlclient-dev
The package also requires setuptools, which is available here. Download it (I’m running Python 2.6.5, so I downloaded setuptools-0.6c11-py2.6.egg) and run it as a shell script.
$ sh ~/Downloads/setuptools-0.6c11-py2.6.egg
A second error — i.e. gcc could not find python.h — was resolved by installing the Python development package.
$ sudo apt-get install python-dev
Back to it …