Python MySQL installing wrongly on Mac OS X 10.6 i386

When trying to install MySQL's python bindings, MySQLdb, I followed the instructions to build and install on my MacBook running Mac OS X 10.6 i386, and after entering the following line into the terminal:

user-152-3-158-79:MySQL-python-1.2.3c1 jianweigan$ sudo python setup.py build

I get the following errors:

running build
running build_py
creating build/lib.macosx-10.3-i386-2.6
copying _mysql_exceptions.py -> build/lib.macosx-10.3-i386-2.6
creating build/lib.macosx-10.3-i386-2.6/MySQLdb
copying MySQLdb/__init__.py -> build/lib.macosx-10.3-i386-2.6/MySQLdb
copying MySQLdb/converters.py -> build/lib.macosx-10.3-i386-2.6/MySQLdb
copying MySQLdb/connections.py -> build/lib.macosx-10.3-i386-2.6/MySQLdb
copying MySQLdb/cursors.py -> build/lib.macosx-10.3-i386-2.6/MySQLdb
copying MySQLdb/release.py -> build/lib.macosx-10.3-i386-2.6/MySQLdb
copying MySQLdb/times.py -> build/lib.macosx-10.3-i386-2.6/MySQLdb
creating build/lib.macosx-10.3-i386-2.6/MySQLdb/constants
copying MySQLdb/constants/__init__.py -> build/lib.macosx-10.3-i386-2.6/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.macosx-10.3-i386-2.6/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10.3-i386-2.6/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.macosx-10.3-i386-2.6/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.3-i386-2.6/MySQLdb/constants
copying MySQLdb/constants/REFRESH.py -> build/lib.macosx-10.3-i386-2.6/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.3-i386-2.6/MySQLdb/constants
running build_ext
building '_mysql' extension
creating build/temp.macosx-10.3-i386-2.6
Compiling with an SDK that doesn't seem to exist: /Developer/SDKs/MacOSX10.4u.sdk
Please check your Xcode installation

It looks like the setup.py build script is recognizing my OS as Mac OS X 10.3 instead of 10.6 so it tries to locate an older version of XCode which I don't have.

Does anyone know how to get around this problem? Perhaps manually configuring the script to recognize my os as 10.6?

13.10.2009 19:09:36
3 ОТВЕТА
РЕШЕНИЕ

It appears you have installed and are using a python.org python2.6. Because that installer is designed to work for a range of systems, to build extensions with that python on 10.6, you need to install the optional 10.4 SDK which is part of the Xcode package on the Snow Leopard installation DVD or machine restore DVD; the 10.4 SDK is not installed by default. That's what the message is trying to tell you.

9
13.10.2009 19:34:22
Is there also a prepackaged python2.6 that comes with Snow Leopard that's different from python.org's python2.6?
Wei 13.10.2009 19:44:35
Yes, Apple supplies a Python 2.6.1 (and a 2.5) as part of Snow Leopard. Their canonical locations are /usr/bin/python2.6 (and /usr/bin/python2.5) and by default /usr/bin/python links to /usr/bin/python2.6. By default, the python.org installers create symlinks in /usr/local/bin, so /usr/local/bin/python2.6, etc, and the most recent install changes /usr/local/bin/python. Then you can also install pythons from MacPorts or Fink. So it's always a bit of a crap shoot which python you will end up with if you just type "python" unless you are careful with the order of directories on your $PATH.
Ned Deily 13.10.2009 20:56:07
BTW, there's nothing wrong with using the python.org python: there are newer versions available there (Apple's is currently 2.6.1, python.org is now at 2.6.3 with 2.6.4 to follow very soon). Nothing wrong with using Apple's, either. Apples vs snakes, perhaps?
Ned Deily 13.10.2009 20:59:26

Well the error is pretty clear, do you have xcode installed? http://developer.apple.com/tools/Xcode/

You can look at a more detailed solution to this in http://blog.some-abstract-type.com/2009/09/mysql-python-and-mac-os-x-106-snow.html which includes downloading the latest xcode. Hope it helps.

-1
13.10.2009 19:25:27

Installing the latest version of Python from python.org, fixed this problem for me.

1
5.10.2011 08:11:29