0

Running OSX 10.6.3

Just updated python to Python 2.6.5 (r265:79359

rebuilt and reinstalled mysqldb (MySQL-python-1.2.3)

rebuilt and reinstalled django (<-- should be unrelated. problem seems to be with mysqldb)

I'm getting the following error.

File "<stdin>", line 1, in <module>
File "build/bdist.macosx-10.3-fat/egg/MySQLdb/__init__.py", line 19, in <module>    
File "build/bdist.macosx-10.3-fat/egg/_mysql.py", line 7, in <module>
  File "build/bdist.macosx-10.3-fat/egg/_mysql.py", line 6, in __bootstrap__
ImportError: dlopen(/Users/joshuamerriam/.python-eggs/MySQL_python-1.2.3-py2.6-macosx-10.3-fat.egg-tmp/_mysql.so, 2): Symbol not found: _mysql_affected_rows
  Referenced from: /Users/joshuamerriam/.python-eggs/MySQL_python-1.2.3-py2.6-macosx-10.3-fat.egg-tmp/_mysql.so
  Expected in: dynamic lookup

The error is mentioned here (http://mysql-python.sourceforge.net/FAQ.html) but with no reference as to how to fix it. I'm a bit over my head. Any help?

Piper Merriam
  • 2,774
  • 2
  • 24
  • 30
  • Related: http://stackoverflow.com/questions/1299013/problem-using-mysqldb-symbol-not-found-mysql-affected-rows and http://stackoverflow.com/questions/1907540/problems-installing-mysql-python-1-2-3c1-on-mac-snow-leopard – Mark Jul 17 '10 at 17:36
  • Yeah. Meant to link that one. Tried the steps there and still have the problem. – Piper Merriam Jul 17 '10 at 17:36

2 Answers2

1

Actually, the text of the page you link to does hint at a possible solution:

This is one from Mac OS X. It seems to have been a compiler mismatch, but this time between two different versions of GCC. It seems nearly every major release of GCC changes the ABI in some why, so linking code compiled with GCC-3.3 and GCC-4.0, for example, can be problematic.

It looks like the MySQL client library that mysqldb links against may have been compiled with an older or incompatible version of GCC.

Since the steps outlined in the other answers didn't work for you, here is what I would suggest you try (I've not tested this myself):

  • Download and build the source for the MySQL client library, installing it somewhere out of the way (e.g. /your/homedir/usr-mysql/).
  • Rebuild mysqldb manually, editing site.cfg to point the mysql_config variable to e.g. /your/homedir/usr-mysql/bin/mysql_config)
  • Try using it again.

(Note that there's no need to worry about the MySQL server -- the client libraries always use the MySQL network protocol to communicate with it, even if the connection is just going through a local socket.)

Nicholas Knight
  • 15,774
  • 5
  • 45
  • 57
  • I attempted this method using a macports install of mysql5. I removed mysql5 from my system and then reinstalled using macports which I think does a fresh build if I understood the output correctly. I am still receiving the error, though I'm not sure if a macports version is enough. Any other options? – Piper Merriam Jul 17 '10 at 18:21
1

Since you have already gone done the road of using MacPorts for the MySQL client library, the easiest and least trouble-prone solution long-term is to use as many other components from MacPorts as possible. That is, use python and the the MySQLdb from MacPorts as well. There's even a Django port available. One tip: on Snow Leopard, the MacPorts Python 2.6 Tkinter pulls in a lot of extra ports that you may not want to bother building. If you don't anticipate needing Tkinter, you can skip building it:

sudo port install python26 +no_tkinter py26-mysql py26-django

You may also want to install the python_select port and use it to select the default for the /opt/local/bin/python command:

sudo python_select python26

You'll need to ensure your shell PATH includes the MacPorts bin and Python framework bin directories:

export PATH="/opt/local/Library/Frameworks/Python.framework/Versions/2.6/bin:/opt/local/bin:$PATH"
Ned Deily
  • 83,389
  • 16
  • 128
  • 151
  • After much frustration, mostly because I was installing py-mysql instead of py26-mysql, I've got this working well by using python_selector to use macports. I am still annoyed that I don't know enough to get it working the other way but this will have to do for now. Thanks. – Piper Merriam Jul 20 '10 at 15:07
  • Getting a working MySQLdb installed on OS X has been a headache for a long time. To be successful you need to ensure that the C components of Python, MySQLdb, and the MySQL client libraries are all built in a compatible way. For various reasons, that is not as easy as one might think. A big advantage of using a package manager like MacPorts or Fink is that it takes the guesswork and magic out of this. – Ned Deily Jul 20 '10 at 17:40