DogAndPanda: Getting MYSQL and Python on OSX working.html

Getting MYSQL and Python on OSX working.html

My goal was to get MYSQL and Python working on my OSX Macbook in order to get some simple development and testing done locally.

I thought that this would be simple, but after following what I thought were the necessary steps, I got this error:

File "build/bdist.macosx-10.5-i386/egg/MySQLdb/__init__.py", line 19, in 
ImportError: dynamic module does not define init function (init_mysql)

Some googling says that in order to address this I would have to recompile some stuff with different lags, but these pages prove to be badly researched and incorrect - although that MIGHT fix the problem.

Apparently, this error is caused by pieces of python/mysql being of different architectures (i.e. 32 bit vs 64 bit)... To get python and mysql working WITHOUT recompiling, this is what I did (my OSX system has python 64-bit installed, so I decided to start working with that assumption)..

  • 1. Install the 64 bit package from the link path starting here: http://dev.mysql.com/doc/refman/5.0/en/getting-mysql.html (MAKE SURE you install the 64bit OSX one)
  • 1a. Make sure your path includes the install location from this (like:
    $ cat ~/.bashrc
    export PATH=/usr/local/mysql-5.1.42-osx10.5-x86_64/bin:$PATH
    
  • 2. Download mysql-python from http://sourceforge.net/projects/mysql-python/
  • 3. Follow the instructions in the README after extracting these files. Setup and install are straightforward. It should compile in 64-bit (make sure to watch the CC flags to double check).

    And.. that's it. Everything should work!

    Have a comment?

    Comments