Friday, April 03, 2009

MySQL, OS X and easy_install MySQL-python...

I wonder, sometimes, if as developers we find excuses to hack at code. Part of today's chores had me installing MySQL, and the python DB connector, on my Mac Book Pro. It goes very quickly until I found myself today staring at this error:
$ sudo easy_install -Z MySQL-python
...
EnvironmentError: mysql_config not found
As always, I started by Googling to see who else had hit this problem. The first few hits were all unanimous, you had to edit the setup_posix.py that ships with MySQL-python and change the path to match your OS X environment.

Yes, I'm sure that would work, but the setup_posix.py isn't doing a "/go/to/this/bad/path/mysql_config ..." it's just doing "mysql_config ...".

In other words you can fix everything, and use easy_install by doing a simple:
$ PATH=/usr/local/mysql/bin:$PATH
(Make sure to adjust for the shell you're using!)
And then run the easy_install, everything goes fine.

Simple! MySQL 5.1.33 and MySQL-python 1.2.3 on OS X 10.5.

3 comments:

Ehrich said...

Simple solutions to complex problems are not allowed :-p

zack said...

I just opened up setup_posix.py in TextMate and edited it like this:

# mysql_config.path = "mysql_config"
mysql_config.path = "/usr/local/mysql-5.1.36-osx10.5-x86/bin/mysql_config"

see here: http://www.kinkylemon.nl/blog/07/2009/installing-mysql-python-1-2-3-on-os-x-10-5/

Edwin Watkeys said...

You can also do something like this:

# PATH=$PATH:/usr/local/mysql-5.1.36-osx10.5-x86/bin sudo easy_install -Z MySQL-python

That's one line, by the way That sets PATH for that single command without modifying your shell's environment.