How do I install MySQLdb?#
Download from sourceforge and extract.
$ python setup.py clean $ python setup.py build $ sudo python setup.py install
Mac OS X#You may have to edit setup_posix.py and change the line below (before building):
mysql_config.path = "mysql_config"
mysql_config.path = "/usr/local/mysql/bin/mysql_config"
Note: you have to specify the path to your mysql_config unless you have installed mysql.com package for Mac.
If you get this compile error#
/usr/include/sys/types.h:92: error: duplicate ‘unsigned’ /usr/include/sys/types.h:92: error: two or more data types in declaration specifiers
edit the _mysql.c file and comment out this line
#define uint unsigned int
Make sure if you python is 32 bit, that your MySQL is 32 bit also.
If you are installing MySQLdb in a virtualenv instance, it may be compiling against the system python, which may be 64-bit. Read up on Installing Python Packages.
Python - Linux - MySQL