1

I know this has been asked several times, but after a few hours of trying, there is no way to make this work.

I've installed MySQL 32bits from a dmg file and MySQL-python-1.2.3.

I followed this steps, but when I run python setup.py build, these errors come up:

running build
running build_py
copying MySQLdb/release.py -> build/lib.macosx-10.6-fat-2.6/MySQLdb
running build_ext
building '_mysql' extension
gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -pipe -Dversion_info=(1,2,3,'final',0) -D__version__=1.2.3 -I/usr/local/mysql-5.5.12-osx10.6-x86/include -I/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -c _mysql.c -o build/temp.macosx-10.6-fat-2.6/_mysql.o -Os -g -fno-common -fno-strict-aliasing -arch i386
In file included from _mysql.c:36:
/usr/local/mysql-5.5.12-osx10.6-x86/include/my_config.h:326:1: warning: "SIZEOF_SIZE_T" redefined
In file included from /System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/Python.h:9,
                 from pymemcompat.h:10,
                 from _mysql.c:29:
/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/pymacconfig.h:39:1: warning: this is the location of the previous definition
In file included from _mysql.c:36:
/usr/local/mysql-5.5.12-osx10.6-x86/include/my_config.h:419:1: warning: "HAVE_WCSCOLL" redefined
In file included from /System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/Python.h:8,
                 from pymemcompat.h:10,
                 from _mysql.c:29:
/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/pyconfig.h:803:1: warning: this is the location of the previous definition
_mysql.c:76: error: expected specifier-qualifier-list before ‘MYSQL’
_mysql.c:90: error: expected specifier-qualifier-list before ‘MYSQL_RES’
_mysql.c: In function ‘_mysql_Exception’:
_mysql.c:120: warning: implicit declaration of function ‘mysql_errno’
_mysql.c:120: error: ‘_mysql_ConnectionObject’ has no member named ‘connection’
_mysql.c:132: error: ‘ER_DB_CREATE_EXISTS’ undeclared (first use in this function)
_mysql.c:132: error: (Each undeclared identifier is reported only once

......

I'd appreciate ANY help you can provide. Thanks!

3
  • It looks like the compiler cannot find the MySQL header files. Were header files included with the DMG that you installed? If so, you can point the compiler in the right direction by setting the CFLAGS environment variable. Commented May 15, 2011 at 23:40
  • It contained a few pkg files to install it... Commented May 15, 2011 at 23:43
  • possible duplicate of How to install MySQLdb (Python data access library to MySQL) on Mac OS X? Commented Dec 17, 2011 at 22:53

3 Answers 3

6
+50

Try macports:

$ port search python | grep mysql
py-mysql @1.2.2 (python, devel, databases)
Python interface to mysql
py25-mysql @1.2.2 (python, devel, databases)
Python interface to mysql
py26-mysql @1.2.3 (python, devel, databases)
py27-mysql @1.2.2 (python, devel, databases)
Python interface to mysql
Sign up to request clarification or add additional context in comments.

3 Comments

Hey, thanks! I don't know 100% what I just did, though :D If I run "import MySQLdb" from the Python CLI it doesn't find it. How can I check it is properly installed?
That command doesn't install it. sudo port install py-mysql (or whichever one you want) will, though. And port list | grep py-mysql will show if it's installed.
Yeah, I got it now, I'm installing and see how it goes. Thanks.
3

My answer here worked for me for both a 32-bit and a 64-bit Mac Snow Leopard install (on two different machines): Installing MySQLdb for Django on Mac OS X 10.6 Snow Leopard with MAMP

Short version:

[user]$ sudo su
[root]# ARCHFLAGS="-arch $(uname -m)" pip install mysql-python

Comments

2

If you don't want to deal with the headache of a package manager on your mac, I've detailed my experience in this installation guide: http://alexandersimoes.com/journal/2011/03/04/install-mysqldb-on-mac-osx-snow-leopard/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.