简体   繁体   中英

Installing MySQLdb on Snow Leopard

I'm having all sorts of trouble trying to instal MySQLdb (1.2.2) on snow leopard. I am running python 2.5.1 and MySQL 5.1 32bit.

Python and MySQL are running just fine.

I've also installed django 1.2.1, although I don't think thats all that important, but wanted to give an idea of the stack i'm trying to install. I am using python 2.5.x as my webhost only has that version as an option and I want to be as close to my production env as possible.

anyway...

After following many of the existing articles and tutorials which mention modifying _mysql.c and setup_posix.py etc, I am still running into trouble.

Here is my stack trace:

xxxxxxx-mbp:MySQL-python-1.2.2 xxxxxxx$ sudo ARCHFLAGS="-arch x86_64" python setup.py build running build running build_py creating build creating build/lib.macosx-10.3-i386-2.5 copying _mysql_exceptions.py -> build/lib.macosx-10.3-i386-2.5 creating build/lib.macosx-10.3-i386-2.5/MySQLdb copying MySQLdb/ init .py -> build/lib.macosx-10.3-i386-2.5/MySQLdb copying MySQLdb/converters.py -> build/lib.macosx-10.3-i386-2.5/MySQLdb copying MySQLdb/connections.py -> build/lib.macosx-10.3-i386-2.5/MySQLdb copying MySQLdb/cursors.py -> build/lib.macosx-10.3-i386-2.5/MySQLdb copying MySQLdb/release.py -> build/lib.macosx-10.3-i386-2.5/MySQLdb copying MySQLdb/times.py -> build/lib.macosx-10.3-i386-2.5/MySQLdb creating build/lib.macosx-10.3-i386-2.5/MySQLdb/constants copying MySQLdb/constants/ init .py -> build/lib.macosx-10.3-i386-2.5/MySQLdb/constants copying MySQLdb/constants/CR.py -> build/lib.macosx-10.3-i386-2.5/MySQLdb/constants copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.macosx-10. 3-i386-2.5/MySQLdb/constants copying MySQLdb/constants/ER.py -> build/lib.macosx-10.3-i386-2.5/MySQLdb/constants copying MySQLdb/constants/FLAG.py -> build/lib.macosx-10.3-i386-2.5/MySQLdb/constants copying MySQLdb/constants/REFRESH.py -> build/lib.macosx-10.3-i386-2.5/MySQLdb/constants copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.3-i386-2.5/MySQLdb/constants running build_ext building '_mysql' extension creating build/temp.macosx-10.3-i386-2.5 gcc -isysroot /Developer/SDKs/MacOSX10.4u.sdk -fno-strict-aliasing -Wno-long-double -no-cpp-precomp -mno-fused-madd -fno-common -dynamic -DNDEBUG -g -O3 -Dversion_info=(1,2,2,'final',0) -D__version__=1.2.2 -I/usr/local/mysql-5.1.48-osx10.6-x86/include -I/Library/Frameworks/Python.framework/Versions/2.5/include/python2.5 -c _mysql.c -o build/temp.macosx-10.3-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 In file included from /Developer/SDKs/MacOSX10.4u.sdk/usr/include/wchar.h:112, from /Library/Frameworks/Python.framework/Versions/2.5/include/python2.5/unicodeobject.h:118, from /Library/Frameworks/Python.framework/Versions/2.5/include/python2.5/Python.h:83, from pymemcompat.h:10, from _mysql.c:29: /Developer/SDKs/MacOSX10.4u.sdk/usr/include/stdarg.h:4:25: error: stdarg.h: No such file or directory In file included from _mysql.c:35: /usr/local/mysql-5.1.48-osx10.6-x86/include/my_config.h:1062:1: warning: "HAVE_WCSCOLL" redefined In file included from /Library/Frameworks/Python.framework/Versions/2.5/include/python2.5/Python.h:8, from pymemcompat.h:10, from _mysql.c:29: /Library/Frameworks/Python.framework/Versions/2.5/include/python2.5/pyconfig.h:724:1: warning: this is the location of the previous definition error: command 'gcc' failed with exit status 1

Does anyone have any ideas?

Rather late for the original question, but in case others - like me - are encountering the mystery of a missing stdarg.h, see below. I'm using MacOS X 10.7.3, MySQL 5.5.20, Python 2.7.2, MySQL-python-1.2.3.

My error message:

/Developer/SDKs/MacOSX10.6.sdk/usr/include/stdarg.h:4:25: error: stdarg.h: No such file or directory

The following blog post saved me: http://packetcloud.net/2009/09/22/installing-mysql-python-module-for-python-262-on-snow-leopard-using-xcode/

Summarizing the key bit:

Open up /Developer/SDKs/MacOSX10.6.sdk/usr/include/stdarg.h

Replace the line:

#include_next <stdarg.h>

With:

#include_next </Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/Kernel.framework/Versions/A/Headers/stdarg.h>

Then things work smoothly:

> sudo ARCHFLAGS='-arch x86_64' python setup.py build
> sudo ARCHFLAGS='-arch x86_64' python setup.py install

I usually install packages like this with MacPorts. It's package management software that handles all the downloading, configuring and installing for you. It's just like emerge on gentoo or apt-get on debian.

Make sure you have Xcode installed and install macports . Once you've got that installed, fire up the terminal and install mysql by typing:

$ sudo port install mysql5-server

I tried to solve this one for days myself and finally gave up.

I switched to postgres. It works pretty well with django on snow leopard, with one minor problem. For some reason auto_inc pk ids don't get assigned to some models. I solved the problem by randomly assigning an id from a large random range, and relying on the unique column designation to prevent collisions.

My production server is linux. Mysql and postgres install fine on it.

In fact, many on the #django irc channel recommended running a virtual linux instance on the mac to get around my mysql install problems on it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM