To connect to a MySQL database from Django or a python script you have to install MySQLdb. The installation of the package on MacOSX is not straightforward, so here is a small howto.
mysql_config.path = "mysql_config" to mysql_config.path = "/usr/local/mysql/bin/mysql_config"
Note: you have to specify the path to your mysql_config unless you have installed mysql.com package for mac
python setu.py clean python setup.py build sudo python setup.py install
If you get this compile error
/usr/include/sys/types.h:92: error: duplicate ‘unsigned’ /usr/include/sys/types.h:92: error: two or more data types in declaration specifiers
edit the _mysql.c file and comment this line
#define uint unsigned int
8 Responses
Blogimus
14|May|2008 1Thanks!
This fix got me past my first build problem of the compile error.
I’m building on an iMac G5 running 10.5 Leopard .
I now have the wrong arch warning:
ld: warning in /usr/local/mysql/lib/mysql/libmysqlclient_r.a, file is not of required architecture
so my next step is to fix the arch parameters to support ppc64.
Gene Warner
13|Nov|2008 2b1t4qlhazo4fawez
Turadg
08|Dec|2008 3I hit the same warnings as Blogimus, on an 32-bit Intel Mac, but I went ahead and installed and everything worked okay.
I’ve written up my experience here,
http://openeducationresearch.blogspot.com/2008/12/mysql-with-python-on-mac.html
and created a binary egg for easy_install,
http://www.cs.cmu.edu/%7Etaleahma/projects/misc/MySQL_python-1.2.2-py2.5-macosx-10.5-i386.egg
So you should be able to install this now with this simple command,
easy_install http://www.cs.cmu.edu/%7Etaleahma/projects/misc/MySQL_python-1.2.2-py2.5-macosx-10.5-i386.egg
Thanks for the fix!
Sampath Girish Munagala
19|Jan|2009 4Sampath:MySQL-python-1.2.2 venkatarampey$
Sampath:MySQL-python-1.2.2 venkatarampey$ python setup.py clean
running clean
Sampath:MySQL-python-1.2.2 venkatarampey$ python setup.py build
running build
running build_py
copying MySQLdb/release.py -> build/lib.macosx-10.5-i386-2.5/MySQLdb
running build_ext
building ‘_mysql’ extension
creating build/temp.macosx-10.5-i386-2.5
gcc -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-madd -fno-common -dynamic -DNDEBUG -g -Os -Wall -Wstrict-prototypes -DMACOSX -I/usr/include/ffi -DENABLE_DTRACE -pipe -Dversion_info=(1,2,2,’final’,0) -D__version__=1.2.2 -I/usr/local/mysql/include -I/System/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5 -c _mysql.c -o build/temp.macosx-10.5-i386-2.5/_mysql.o -g -Os -arch i386 -fno-common -D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -DIGNORE_SIGHUP_SIGQUIT -DDONT_DECLARE_CXA_PURE_VIRTUAL
unable to execute gcc: No such file or directory
error: command ‘gcc’ failed with exit status 1
Sampath:MySQL-python-1.2.2 venkatarampey$
“I Got this error after following the above steps mentioned. Anyone can solve this will be very helpful to me. Advance thanks for ur reply”.
Please post ur reply to girishmsampath@gmail.com,girishmsampath@in.com,girishmsampath@yahoo.co.in
Pl keep subject as Solution for Build error in python.
Regards,
Sampath Girish.
David
27|Mar|2009 5I can’t seem to get around this problem on OS 10.4.11 …
building ‘_mysql’ extension
gcc -Wl,-F. -Wl,-F. -bundle -undefined dynamic_lookup build/temp.darwin-8.11.0-Power_Macintosh-2.3/_mysql.o -L/mysql/lib/mysql -lmysqlclient_r -lz -lm -lmygcc -o build/lib.darwin-8.11.0-Power_Macintosh-2.3/_mysql.so
ld: -undefined: unknown argument: dynamic_lookup
error: command ‘gcc’ failed with exit status 1
Powderflask
27|May|2009 6Turadg – brilliant!
your egg installed perfectly – just needed to do one extra step:
libmysqlclient_r.16.dylib is required in /usr/local/mysql/lib/
I had a slightly older version of MySQL (r.15) – downloaded latest MySQL tar (5.1) – works perfect.
Thanks very much for making this a truly easy install.
Arthur
19|Nov|2009 7Good egg!
Andrew
07|Jan|2010 8why not just use the ports system ?
port install py-mysql +mysql5
Leave a reply
Search
Tag Cloud
Categories
Blogroll
A design creation of Design Disease
Copyright © 2007 - Brainfault - is proudly powered by WordPress
InSense 1.0 Theme by Design Disease brought to you by HostGator Web Hosting.