Skip to content

Instantly share code, notes, and snippets.

@narfdotpl
Created December 4, 2010 16:01
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save narfdotpl/728281 to your computer and use it in GitHub Desktop.
Save narfdotpl/728281 to your computer and use it in GitHub Desktop.
MySQLdb, Python 2.5 and OS X 10.6

MySQLdb, Python 2.5 and OS X 10.6

I wasted too much time trying to make MySQLdb work with Python 2.5 (mysteriously it worked fine with 2.7). I thought I'll share my experience.

I installed MySQLdb normally with pip install MySQL-python (yeah, ingenious name) and there were no problems. But every time I imported it, I got following error:

File "build/bdist.macosx-10.6-i386/egg/_mysql.py", line 6, in __bootstrap__
ImportError: dlopen(/Users/narf/.python-eggs/MySQL_python-1.2.3-py2.5-macosx-10.6-i386.egg-tmp/_mysql.so, 2): Symbol not found: _mysql_affected_rows
Referenced from: /Users/narf/.python-eggs/MySQL_python-1.2.3-py2.5-macosx-10.6-i386.egg-tmp/_mysql.so
Expected in: flat namespace

Many people have similar problems. Some solutions require downgrading MySQLdb and patching source by hand. None of this worked for me. What helped was reinstalling MySQL with --universal flag (I use Homebrew):

pip uninstall MySQL-python
brew uninstall mysql
brew install mysql --universal
pip install MySQL-python

Happy djangoing! -_-'

@loganlinn
Copy link

Thanks for saving me the headache :)

@look
Copy link

look commented Apr 1, 2011

Thanks! This worked like a charm. I didn't want to re-install MySQL but it turned out to be pretty easy, thanks to homebrew.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment