ImportError: dynamic module does not define init function (init_mysql)
Traceback (most recent call last):
File "/Users/me/Applications/python/test/src/test.py", line 17, in <module>
import MySQLdb
File "build/bdist.macosx-10.5-i386/egg/MySQLdb/init.py", line 19, in <module>
File "build/bdist.macosx-10.5-i386/egg/_mysql.py", line 7, in <module>
File "build/bdist.macosx-10.5-i386/egg/_mysql.py", line 6, in bootstrap
ImportError: dynamic module does not define init function (init_mysql)
I've tried multiple options to get MySQLdb working on 10.5.6:
I seem to be in a Catch-22 -- the version 2.3/2.5 Pythons that comes with 10.5 won't work, the 3.0 Python can't find the MySQLdb package at all -- and presumably will also miss any other (add-on) local packages I've installed.
Is there any other alternative to dumping out the MySQL data into a suitable flat file format and sucking it back into a python dictionary -- primitive, but probably will work for now -- though I'll pay a price every time the data in the database changes.
Anyone have a MySQLdb fix that works for OS X 10.5.6?
I admit I'm surprised that python, which has been so robust in having libraries and methods for so many things, hasn't got something as simple as a working Mac OS X MySQL interface. Heck, even Perl has multiple to chose from.
Thanks for any assistance ...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Well, after many repeated attempts, the import works. It will be a day or two to transfer my data to the 32-bit MySQL and recreate the databases before I know python's MySQLdb actually works with the MySQL database.
Tips:
0. Assuming you can stomach 32-bit MySQL, move your 64-bit mysql aside (/usr/local/mysql on my system) and reinstall using the 32-bit Mac OS Package .dmg
remove everything under your MySQL-python-1.2.2/build/* directory -- don't trust the "python setup.py clean" to do it for you.
remove the egg under $USER/.python-eggs
Do the usual:
python setup.py clean
python setup.py build
sudo python setup.py install
... and voila. Import returns without error:
$ python
Python 2.5.1 (r251:54863, Jan 13 2009, 10:26:13) [GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
>>>
... now if the calls work, that would be really welcome. :-)
Richard
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Still getting this error:
ImportError: dynamic module does not define init function (init_mysql)
Traceback (most recent call last):
File "/Users/me/Applications/python/test/src/test.py", line 17, in <module>
import MySQLdb
File "build/bdist.macosx-10.5-i386/egg/MySQLdb/init.py", line 19, in <module>
File "build/bdist.macosx-10.5-i386/egg/_mysql.py", line 7, in <module>
File "build/bdist.macosx-10.5-i386/egg/_mysql.py", line 6, in bootstrap
ImportError: dynamic module does not define init function (init_mysql)
I've tried multiple options to get MySQLdb working on 10.5.6:
http://mysql-python.blogspot.com/2008/03/i-am-not-dead.html
http://www.mangoorange.com/2008/08/01/installing-python-mysqldb-122-on-mac-os-x/
... and I've tried Mac Python 3.0.
I seem to be in a Catch-22 -- the version 2.3/2.5 Pythons that comes with 10.5 won't work, the 3.0 Python can't find the MySQLdb package at all -- and presumably will also miss any other (add-on) local packages I've installed.
Is there any other alternative to dumping out the MySQL data into a suitable flat file format and sucking it back into a python dictionary -- primitive, but probably will work for now -- though I'll pay a price every time the data in the database changes.
Anyone have a MySQLdb fix that works for OS X 10.5.6?
I admit I'm surprised that python, which has been so robust in having libraries and methods for so many things, hasn't got something as simple as a working Mac OS X MySQL interface. Heck, even Perl has multiple to chose from.
Thanks for any assistance ...
Well, after many repeated attempts, the import works. It will be a day or two to transfer my data to the 32-bit MySQL and recreate the databases before I know python's MySQLdb actually works with the MySQL database.
Tips:
0. Assuming you can stomach 32-bit MySQL, move your 64-bit mysql aside (/usr/local/mysql on my system) and reinstall using the 32-bit Mac OS Package .dmg
follow the instructions here for source editing, symbolic links and the rest: http://www.mangoorange.com/2008/08/01/installing-python-mysqldb-122-on-mac-os-x/
remove everything under your MySQL-python-1.2.2/build/* directory -- don't trust the "python setup.py clean" to do it for you.
remove the egg under $USER/.python-eggs
Do the usual:
python setup.py clean
python setup.py build
sudo python setup.py install
... and voila. Import returns without error:
$ python
Python 2.5.1 (r251:54863, Jan 13 2009, 10:26:13)
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
>>>
... now if the calls work, that would be really welcome. :-)
Richard