MacOSX に PyPi から MySQL-python インストール時のエラー

MySQLMacPorts から最新をインストール済み。

$ sudo pip install MySQL-python
Downloading/unpacking MySQL-python
  Downloading MySQL-python-1.2.3c1.tar.gz (89Kb): 89Kb downloaded
  Running setup.py egg_info for package MySQL-python
    sh: mysql_config: command not found
    Traceback (most recent call last):
      File "<string>", line 14, in <module>
      File "/tmp/build/MySQL-python/setup.py", line 15, in <module>
        metadata, options = get_config()
      File "setup_posix.py", line 43, in get_config
        libs = mysql_config("libs_r")
      File "setup_posix.py", line 24, in mysql_config
        raise EnvironmentError("%s not found" % (mysql_config.path,))
    EnvironmentError: mysql_config not found
    Complete output from command python setup.py egg_info:
    sh: mysql_config: command not found

Traceback (most recent call last):

  File "<string>", line 14, in <module>

  File "/tmp/build/MySQL-python/setup.py", line 15, in <module>

    metadata, options = get_config()

  File "setup_posix.py", line 43, in get_config

    libs = mysql_config("libs_r")

  File "setup_posix.py", line 24, in mysql_config

    raise EnvironmentError("%s not found" % (mysql_config.path,))

EnvironmentError: mysql_config not found

----------------------------------------
Command python setup.py egg_info failed with error code 1
Storing complete log in /var/root/.pip/pip.log

MacPorts から MySQL をインストールしたら mysql_config5 となるので、以下のようにすればおk。

$ cd /opt/local/bin/
$ sudo ln -s mysql_config5 mysql_config
$ sudo pip install MySQL-python           
Downloading/unpacking MySQL-python
  Running setup.py egg_info for package MySQL-python
Installing collected packages: MySQL-python
  Running setup.py install for MySQL-python
    building '_mysql' extension
    /usr/bin/gcc-4.0 -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Dversion_info=(1,2,3,'gamma',1) -D__version__=1.2.3c1 -I/opt/local/include/mysql5/mysql -I/opt/local/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -c _mysql.c -o build/temp.macosx-10.5-i386-2.6/_mysql.o -fPIC -D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -DIGNORE_SIGHUP_SIGQUIT -DDONT_DECLARE_CXA_PURE_VIRTUAL
    In file included from _mysql.c:36:
    /opt/local/include/mysql5/mysql/my_config.h:1053:1: warning: "HAVE_WCSCOLL" redefined
    In file included from /opt/local/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/Python.h:8,
                     from pymemcompat.h:10,
                     from _mysql.c:29:
    /opt/local/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/pyconfig.h:808:1: warning: this is the location of the previous definition
    /usr/bin/gcc-4.0 -L/opt/local/lib -bundle -undefined dynamic_lookup build/temp.macosx-10.5-i386-2.6/_mysql.o -L/opt/local/lib -L/opt/local/lib/mysql5/mysql -L/opt/local/lib -L/opt/local/lib/ -lmysqlclient_r -lz -lm -lssl -lcrypto -o build/lib.macosx-10.5-i386-2.6/_mysql.so
Successfully installed MySQL-python
Cleaning up...