mysql-python and Snow Leopard

After the upgrade to Snow Leopard, mysql-python cannot be installed through easy_install.

* Install mysql’s x86_64 version from the .dmg file (I had a problem doing this when booted into the 64bit kernel, a 32bit kernel macbook had no problem) With the 64bit kernel, the system reported ‘no mountable file systems’ when trying to mount the .dmg file. A reboot into 32bit mode allowed the .dmg to be mounted and installed.
* Change into your virtual environment if desired, source bin/activate
* fetch MySQL-python-1.2.3c1

tar xzf MySQL-python-1.2.3c1.tar.gz
cd MySQL-python-1.2.3c1
ARCHFLAGS='-arch x86_64' python setup.py build
ARCHFLAGS='-arch x86_64' python setup.py install

If everything works, you should see:

$ python
Python 2.6.1 (r261:67515, Jul  7 2009, 23:51:51) 
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
>>>

Some of the possible things you’ll encounter:

After python setup.py build:

ld: warning: in build/temp.macosx-10.6-universal-2.6/_mysql.o, file is not of required architecture
ld: warning: in /usr/local/mysql/lib/libmysqlclient.dylib, file is not of required architecture
ld: warning: in /usr/local/mysql/lib/libmygcc.a, file is not of required architecture
ld: warning: in build/temp.macosx-10.6-universal-2.6/_mysql.o, file is not of required architecture
ld: warning: in /usr/local/mysql/lib/libmysqlclient.dylib, file is not of required architecture
ld: warning: in /usr/local/mysql/lib/libmygcc.a, file is not of required architecture

This means that you have the i386 version of mysql installed. Or, if you have the x86_64 version, you have didn’t include the proper ARCHFLAGS command.

ImportError: dynamic module does not define init function (init_mysql)

this means that the easy_install or the build/install process was run which tried to build a ppc/i386/x86_64 combined build.

If you see messages like:

$ python
Python 2.6.1 (r261:67515, Jul  7 2009, 23:51:51) 
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
/Users/xxxxx/Python/django/lib/python2.6/site-packages/MySQL_python-1.2.3c1-py2.6-macosx-10.6-universal.egg/_mysql.py:3: UserWarning: Module _mysql was already imported from /Users/xxxxx/Python/django/lib/python2.6/site-packages/MySQL_python-1.2.3c1-py2.6-macosx-10.6-universal.egg/_mysql.pyc, but /Users/xxxxx/Python/django/MySQL-python-1.2.3c1 is being added to sys.path
>>> 

Then you are still in the build directory. cd .. and try again.

Tags: , , ,

42 Responses to “mysql-python and Snow Leopard”

  1. samuel.goldszmidt Says:

    hello

    thx for your post, i tried it and i get this :
    bash-3.2# ARCHFLAGS=’-arch x86_64′ python setup.py build
    running build
    running build_py
    copying MySQLdb/release.py -> build/lib.macosx-10.6-universal-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,’gamma’,1) -D__version__=1.2.3c1 -I/usr/local/mysql/include -I/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -c _mysql.c -o build/temp.macosx-10.6-universal-2.6/_mysql.o -g -Os -arch x86_64 -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-4.2: No such file or directory
    error: command ‘gcc-4.2’ failed with exit status 1

    but i can’t get gcc working on my mac snow leopard, any issue ?

    thanks

  2. cd34 Says:

    Put in the Snow Leopard Install DVD, go to Optional Installs, double-click Xcode to install it.

    Once you’ve done that, you should have gcc and gcc-4.2.

  3. Seth Gottlieb Says:

    Could you explain a little more about how to correct the “Import Error” issue? I am getting that and I am not sure why. I am running MySQL under 64 bit (using Hivelogic’s instructions: http://hivelogic.com/articles/compiling-mysql-on-snow-leopard/). I am running Apple’s Python 2.6 under 65 bit. I am using the ARCHFLAGS option when I build and install the MySQL-python source. Are there any other areas that I should be looking?

  4. cd34 Says:

    If you get the import error mentioning the paths, then you are still in the build directory. Change to a different directory and the path messages should go away. Basically, when you do your import, it finds a copy in your syspath, and, a copy in the directory below where you just built the module. It doesn’t know which to use, so, it is warning you that there were two different imports of the same name found.

  5. Seth Gottlieb Says:

    Thanks for following up. Nothing about paths:

    >>> import MySQLdb
    Traceback (most recent call last):
    File “”, line 1, in
    File “build/bdist.macosx-10.6-universal/egg/MySQLdb/__init__.py”, line 19, in
    File “build/bdist.macosx-10.6-universal/egg/_mysql.py”, line 7, in
    File “build/bdist.macosx-10.6-universal/egg/_mysql.py”, line 6, in __bootstrap__
    ImportError: dynamic module does not define init function (init_mysql)

    Django syncdb doesn’t work either for the same reason.

  6. discoraver Says:

    I have installed x86_64 version of MySQL 5.1.38 & that seems to be running fine. I have Xcode 3.1 Beta installed, i686-apple-darwin10-gcc-4.2.1. I am using Python 2.6.2.

    the MySQLdb build fails with the following error:

    running build
    running build_py
    copying MySQLdb/release.py -> build/lib.macosx-10.3-fat64-2.6/MySQLdb
    running build_ext
    building ‘_mysql’ extension
    Compiling with an SDK that doesn’t seem to exist: /Developer/SDKs/MacOSX10.4u.sdk
    Please check your Xcode installation
    gcc -isysroot /Developer/SDKs/MacOSX10.4u.sdk -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -O3 -Dversion_info=(1,2,3,’gamma’,1) -D__version__=1.2.3c1 -I/usr/local/mysql/include -I/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -c _mysql.c -o build/temp.macosx-10.3-fat64-2.6/_mysql.o -g -Os -arch x86_64 -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 pymemcompat.h:10,
    from _mysql.c:29:

    Any ideas as to what’s going wrong?

  7. Seth Gottlieb Says:

    @discoraver Did you do the XCode install from the Snow Leopard disc?

  8. Seth Gottlieb Says:

    One other strange thing about my issue is that the path referenced in the error message does not seem to exist:

    seth-gottliebs-computer:~ sethgottlieb$ python
    Python 2.6.1 (r261:67515, Jul 7 2009, 23:51:51)
    [GCC 4.2.1 (Apple Inc. build 5646)] on darwin
    Type “help”, “copyright”, “credits” or “license” for more information.
    >>> import MySQLdb
    Traceback (most recent call last):
    File “”, line 1, in
    File “build/bdist.macosx-10.6-universal/egg/MySQLdb/__init__.py”, line 19, in
    File “build/bdist.macosx-10.6-universal/egg/_mysql.py”, line 7, in
    File “build/bdist.macosx-10.6-universal/egg/_mysql.py”, line 6, in __bootstrap__
    ImportError: dynamic module does not define init function (init_mysql)
    >>> ^D
    seth-gottliebs-computer:~ sethgottlieb$ mdfind -name bdist.macosx-10.6-universal
    seth-gottliebs-computer:~ sethgottlieb$

  9. cd34 Says:

    I think in your build directory you have built without the ARCHFLAGS, and then tried to build afterwards. make will not notice the archflags difference and will just try to install based on the object code.

    In your build directory, try:
    make clean
    python setup.py build
    python setup.py install

    The issue you are having is hidden by easy_install which won’t show you the errors, but, a build SHOULD show you an error. If the build process after make clean shows an error, that is the place to start debugging. I would suspect based on the lines above that you have an old build without the ARCHFLAGS that is just being linked rather than recompiled with the archflags.

  10. cd34 Says:

    @discoraver, you are missing the Snow Leopard SDK which is on the DVD.

    /Developer/SDKs/MacOSX10.6.sdk/

    Reinstall XCode from the DVD and you should be set. During the upgrade to Snow Leopard, XCode doesn’t get updated.

  11. btaylordesign Says:

    I’m also running the custom build of MySQL from Hivelogic, and it is running as expected. When I attempt to compile MySQL-Python, I receive this error:

    /Developer/SDKs/MacOSX10.4u.sdk/usr/include/stdarg.h:4:25: error: stdarg.h: No such file or directory
    error: command ‘gcc’ failed with exit status 1

    That’s on a fresh install of XCode from the Snow Leopard DVD. I’m looking right at the directory and file it can’t find right now.

    I would really appreciate some pointers!

    Cheers,
    Brandon

  12. cd34 Says:

    The path you have listed above, lists the SDK for 10.4.

    The fact that gcc cannot find that file suggests that the SDK didn’t get installed properly. Did you run the installer, or copy it into the directory?

    $ which gcc
    /usr/bin/gcc

    $ file /usr/bin/gcc
    /usr/bin/gcc: Mach-O universal binary with 3 architectures
    /usr/bin/gcc (for architecture i386): Mach-O executable i386
    /usr/bin/gcc (for architecture ppc7400): Mach-O executable ppc
    /usr/bin/gcc (for architecture x86_64): Mach-O 64-bit executable x86_64

    $ gcc -v
    Using built-in specs.
    Target: i686-apple-darwin10
    Configured with: /var/tmp/gcc/gcc-5646~6/src/configure –disable-checking –enable-werror –prefix=/usr –mandir=/share/man –enable-languages=c,objc,c++,obj-c++ –program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ –with-slibdir=/usr/lib –build=i686-apple-darwin10 –with-gxx-include-dir=/include/c++/4.2.1 –program-prefix=i686-apple-darwin10- –host=x86_64-apple-darwin10 –target=i686-apple-darwin10
    Thread model: posix
    gcc version 4.2.1 (Apple Inc. build 5646)

    The SDK included on Snow Leopard is 10.6:

    $ ls -al /Developer/SDKs/
    total 0
    drwxr-xr-x 4 root wheel 136 Aug 31 16:00 .
    drwxrwxr-x@ 16 root admin 544 Aug 31 16:04 ..
    drwxr-xr-x 7 root wheel 238 Jun 30 02:00 MacOSX10.5.sdk
    drwxr-xr-x 7 root wheel 238 Aug 3 04:19 MacOSX10.6.sdk

    Something is definitely missing from your installation.

    I cannot imagine your path doesn’t include /usr/bin, though, it is possible that the gcc you are using is not the one from the 10.6 SDK.

    $ set|grep bin
    BASH=/bin/bash
    PATH=/sw/bin:/sw/sbin:/usr/local/mysql/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/X11R6/bin
    SHELL=/bin/bash

  13. btaylordesign Says:

    Hi. I ran the XCode installer straight from the Snow Leopard disc.

    My output from your commands is:

    iMac:~ bt$ which gcc
    /usr/bin/gcc

    iMac:~ bt$ file /usr/bin/gcc
    /usr/bin/gcc: Mach-O universal binary with 3 architectures
    /usr/bin/gcc (for architecture i386): Mach-O executable i386
    /usr/bin/gcc (for architecture ppc7400): Mach-O executable ppc
    /usr/bin/gcc (for architecture x86_64): Mach-O 64-bit executable x86_64

    iMac:~ bt$ gcc -v
    Using built-in specs.
    Target: i686-apple-darwin10
    Configured with: /var/tmp/gcc/gcc-5646~6/src/configure –disable-checking –enable-werror –prefix=/usr –mandir=/share/man –enable-languages=c,objc,c++,obj-c++ –program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ –with-slibdir=/usr/lib –build=i686-apple-darwin10 –with-gxx-include-dir=/include/c++/4.2.1 –program-prefix=i686-apple-darwin10- –host=x86_64-apple-darwin10 –target=i686-apple-darwin10
    Thread model: posix
    gcc version 4.2.1 (Apple Inc. build 5646)

    iMac:~ bt$ ls -al /Developer/SDKs/
    total 0
    drwxr-xr-x 5 root wheel 170 Sep 9 18:41 .
    drwxrwxr-x@ 15 root admin 510 Sep 9 18:43 ..
    drwxr-xr-x 7 root wheel 238 May 18 12:24 MacOSX10.4u.sdk
    drwxr-xr-x 7 root wheel 238 Jun 30 01:00 MacOSX10.5.sdk
    drwxr-xr-x 7 root wheel 238 Aug 3 03:19 MacOSX10.6.sdk

    iMac:~ bt$ set|grep bin
    BASH=/bin/bash
    PATH=/sw/bin:/sw/sbin:/Users/bt/source/scala-2.7.4.final/bin:/source/groovy-1.5.6/bin:/source/grails-1.0.3/bin:/usr/local/lib/python2.5/site-packages/django/bin:/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/Users/bt/jruby/bin:/usr/local/src/apache-ant-1.7.0/bin:/Library/Frameworks/Python.framework/Versions/Current/bin:/usr/local/:/usr/local/pgsql/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/opt/local/bin:/usr/X11R6/bin
    SHELL=/bin/bash

    I’ll try trashing and re-installing XCode.

  14. cd34 Says:

    I really wonder if having the 10.4u sdk is creating the problem.

    Can you move that into another directory temporarily. The fact that it keeps finding that sdk is what is causing the problem. If that works, then it might make sense to put a libpath in the python setup.py build process.

  15. Seth Gottlieb Says:

    Just an update. I am up and working after downgrading to Python 2.6 in 32 bit mode and then following these instructions: http://www.zen-hacking.com/2009/09/01/python-mysql-under-snow-leopard

  16. btaylordesign Says:

    Same friggin error, even after re-installing XCode. I think I’m going to try downgrading to the 32bit MySQL and going from there. It’s just for my local dev environment anyway, so is no biggie.

    What I would love to get working, however, is Django 1.0.3 on Jython 2.5.0 with Postgres.

  17. thedailykittenkrew Says:

    @ btaylordesign

    I was having the same problem with the missing “stdarg.h” (even though the file is there). I ended up pasting the contents of stdarg.h from the 10.6 SDK ( /Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/Kernel.framework/Versions/A/Headers/stdarg.h )into that file and was able to then compile it successfully. A BIG warning: I don’t really know what I’m doing (just enough to be dangerous).

    I figured out that the contents of the original stdarg.h contained an “#include_next” statement instead of the expected contents of a stdarg.h file. For some reason the compiler coundn’t find the “next” stdarg.h file and was then reporting that as the error.

  18. btaylordesign Says:

    Hi thedailykittenkrew. No dice for me, I still get the same compiler error.

  19. cd34 Says:

    The thing that seems evident is that everyone that has problems, has the 10.4 SDK installed. If someone can, try moving the 10.4 SDK out of the way and see if it properly compiles. If so, then a libpath needs to be passed to the setup.

  20. btaylordesign Says:

    Can someone please give an example of how to set the libpath to point to the 10.6 SDK?

  21. edwinwillmore Says:

    I had been having problems today trying to get python and mysql to work nice on SL. These comments helped me find a solution, but it isn’t here. My problems mirrored btaylordesign’s problems: no stdarg.h

    If you look at stdarg.h in the 10.4u sdk, it says that gcc uses its own copy of the file. If you peruse the 10.5 sdk and 10.6 sdk, you’ll find gcc4.0 has a very different stdarg.h. These headers aren’t in the 10.4u sdk, nor are there any stdarg.h headers around for gcc4.2. The build is looking for the gcc version of stdarg.h, which doesn’t exist. But if you use gcc4.0.1 then the build will work.

    My solution was to change the gcc version used to build to 4.0. This only means I changed the sym link in /usr/bin since gcc_select is no longer in osx. In my case I also took out the _64 since I’m only using the 32 bit versions. Thus:
    ARCHFLAGS=’-arch x86′ python setup.py build

    I suspect thedailykittenkrew moved the gcc4.0 header file over, not /Developer/SDKs/MacOSX10.5.sdk/usr/include/stdarg.h, which is identical to /Developer/SDKs/MacOSX10.4u.sdk/usr/include/stdarg.h

    Hope this helps someone.

  22. cd34 Says:

    CC=/usr/bin/gcc-4.0 python setup.py build
    CC=/usr/bin/gcc-4.0 python setup.py install

    Might help.

  23. btaylordesign Says:

    Still no dice for me. Looks like I may need to try re-installing Snow Leopard clean on my iMac, which I want to do anyway, or just use Ubuntu on my laptop which works perfectly :\

  24. jkeane Says:

    Similar to seth gottlieb I was having repeated problems and these directions. I would build according to the instructions but still get:

    >>> import MySQLdb
    Traceback (most recent call last):
    File “”, line 1, in
    File “build/bdist.macosx-10.6-universal/egg/MySQLdb/__init__.py”, line 19, in
    File “build/bdist.macosx-10.6-universal/egg/_mysql.py”, line 7, in
    File “build/bdist.macosx-10.6-universal/egg/_mysql.py”, line 6, in __bootstrap__
    ImportError: dynamic module does not define init function (init_mysql)

    After a lot of googling I finally found the problem: python setup.py clean will not actually clean the build/ directory if you’ve built without the proper architecture flags. In order to do this delete everything in the build/ directory with rm * or the like, and then build with the instructions above and everything will work out. cf http://www.mangoorange.com/2008/08/01/installing-python-mysqldb-122-on-mac-os-x/?cp=all comment 10.

  25. filip.bonnevier Says:

    Here we go. I was (kind of, see below) succesful with the following:

    1. Install SDK 10.4u from the Snow Leopard DVD (Optional installs -> XCode.mpkg)

    2. Do the all the tricks described here: http://www.mangoorange.com/2008/08/01/installing-python-mysqldb-122-on-mac-os-x/?cp=all (NOT SURE THIS IS NEEDED THOUGH).

    3. Run the following commands:
    sudo python setup.py clean
    sudo ARCHFLAGS=’-arch x86′ CC=/usr/bin/gcc-4.0 python setup.py build
    sudo ARCHFLAGS=’-arch x86′ CC=/usr/bin/gcc-4.0 python setup.py install

    I have the following versions:
    * mysql-5.1.38-osx10.5-x86 (32-bit)
    * Python 2.6.2
    * MySQL-python-1.2.2

    HOWEVER, I do get the following error on importing MySQLdb in python:
    >>> import MySQLdb
    /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/MySQL_python-1.2.2-py2.6-macosx-10.3-fat.egg/MySQLdb/__init__.py:34: DeprecationWarning: the sets module is deprecated

    Don’t know if it matters…

  26. scot hacker’s foobar blog » Python-MySQL Connections on Mac OS Says:

    […] More info Filed under: Web Dev, Django @ 1:33 am Comments (30) […]

  27. grant.eagon Says:

    Hi, I’ve been struggling with this for a long time now. I’ve installed x86_64 mysql, built with the arch flags set. Install seems to succeed, but when I import MySQLdb, I get the following error:

    >>> import MySQLdb
    Traceback (most recent call last):
    File “”, line 1, in
    File “build/bdist.macosx-10.3-fat/egg/MySQLdb/__init__.py”, line 19, in
    File “build/bdist.macosx-10.3-fat/egg/_mysql.py”, line 7, in
    File “build/bdist.macosx-10.3-fat/egg/_mysql.py”, line 6, in __bootstrap__
    ImportError: dlopen(/Users/granteagon/.python-eggs/MySQL_python-1.2.3c1-py2.6-macosx-10.3-fat.egg-tmp/_mysql.so, 2): Library not loaded: /usr/local/mysql/lib/libmysqlclient_r.16.dylib
    Referenced from: /Users/granteagon/.python-eggs/MySQL_python-1.2.3c1-py2.6-macosx-10.3-fat.egg-tmp/_mysql.so
    Reason: no suitable image found. Did find:
    /usr/local/mysql/lib/libmysqlclient_r.16.dylib: mach-o, but wrong architecture

    Any help would be greatly appreciated. -G

  28. pilardi Says:

    In order to make it work on my system: Snow leopard i386, I had to force python to run in 32 bits mode. So if you want to use 32 bits mysql version, and you are using python > 2.5 you have to force python to use 32 bit architecture, since by default it uses 64 bits. note: osx 10.6 comes with python 2.6 by default.

    You can set it system wide by doing in your console:

    defaults write com.apple.versioner.python Prefer-32-Bit -bool yes

    or just in your session:

    export VERSIONER_PYTHON_PREFER_32_BIT=yes

    , also I had to force the gcc compiler to use 32 bit architecture when building:

    ARCHFLAGS=’-arch i386′

    hope it helps someone, it really helped me!

    – Pablo

  29. m593026 Says:

    I had to massage one of the lines that was failing (the infamous 10.4u sdk one) into this:

    gcc-4.0 -isysroot /Developer/SDKs/MacOSX10.6.sdk -g -bundle -undefined dynamic_lookup build/temp.macosx-10.3-fat-2.6/_mysql.o -L/usr/local/mysql/lib -lmysqlclient_r -lz -lm -lmygcc -o build/lib.macosx-10.3-fat-2.6/_mysql.so

    and it successfully built and installed. I removed the archflags entirely and it worked.

    however when i try to import it…:

    Python 2.6.4 (r264:75821M, Oct 27 2009, 19:48:32)
    [GCC 4.0.1 (Apple Inc. build 5493)] on darwin
    Type “help”, “copyright”, “credits” or “license” for more information.
    >>> import MySQLdb
    Traceback (most recent call last):
    File “”, line 1, in
    File “build/bdist.macosx-10.3-fat/egg/MySQLdb/__init__.py”, line 19, in
    File “build/bdist.macosx-10.3-fat/egg/_mysql.py”, line 7, in
    File “build/bdist.macosx-10.3-fat/egg/_mysql.py”, line 6, in __bootstrap__
    ImportError: dynamic module does not define init function (init_mysql)
    >>>

    Is this due to my omission of the ARCHflags? Any ideas?

  30. cd34 Says:

    python setup.py clean doesn’t remove the remnants from your previous failed build.

    Try

    make clean
    python setup.py clean

    and build it again, or, worst case, remove and unpack the .tgz again and build with the command line you used. I believe the problem exists because you have some .o files from a previous build.

  31. gelliott Says:

    ok, as of dec 3, here is how i got it to work (assembling all the info so far into one spot):

    versions:
    mysql adapter for python: 1.2.3c1
    mysql: 5.1.41 32-bit version
    default python for snow leopard: 2.6.1

    1.install mysql package: http://dev.mysql.com/downloads/mysql/5.1.html#macosx-dmg

    2. grab mysql adapter for python: http://sourceforge.net/projects/mysql-python/files/

    3.in directory for mysql for python:
    Edit the setup_posix.py and change the following

    mysql_config.path = “mysql_config”

    to

    mysql_config.path = “/usr/local/mysql/bin/mysql_config”

    4. sudo ARCHFLAGS=’-arch i386′ CC=/usr/bin/gcc-4.0 python setup.py build

    5. sudo ARCHFLAGS=’-arch i386′ CC=/usr/bin/gcc-4.0 python setup.py install

    6. force python to be 32-bit
    defaults write com.apple.versioner.python Prefer-32-Bit -bool yes

    7. python
    Greg-Elliotts-Mac-Pro:~ greg$ python
    Python 2.6.1 (r261:67515, Jul 7 2009, 23:51:51)
    [GCC 4.2.1 (Apple Inc. build 5646)] on darwin
    Type “help”, “copyright”, “credits” or “license” for more information.
    >>> import MySQLdb
    >>>

  32. WombatNation » MySQL Support from Python on OS X Says:

    […] Update 12/27/2009: With MySQL 5.1.41 and Snow Leopard (OS X 10.6), you no longer need to create the lib/mysql directory with symbolic links as described in the above article. Also, since Snow Leopard comes with Python 2.6, the path above for Eclipse should be /Library/Python/2.6/site-packages. I found Geert’s instructions to be quite helpful for Snow Leopard. There’s also a lot of useful info here. […]

  33. ssteiner Says:

    I had the same problem, then noticed that I was installing with ’sudo’ while building as my regular user.

    See: http://websaucesoftware.com/blog/?p=461 and part 2 at http://websaucesoftware.com/blog/?p=462

    No need to change to 32 bit mode and screw everything up, just install the one with the right architecture!

  34. bialecki Says:

    @jkeane (re comment #24), manually deleting the contents of the build directory fixed my problem with the import error. Really annoying, but thanks for the tip.

  35. Sophomore Dev » Creating my first complete Django project on Snow Leopard Says:

    […] dice, still not working. Poking through the comments of the post above, I came across this indicating that re-building doesn’t actually do it from scratch and you need to go into the […]

  36. j-m15 Says:

    For the sake of sanity, make sure to use sudo and check python to see if you’re running the correct one if you just installed the newest python. Best way to check it’s archs is to type “file $(which python)” without the quotes and it will tell you. Also be sure that typing “file $(which mysql)” also shows whichever arch type you’re going for. It really does matter if your arch types are different, I’ve spent many hours fiddling with this more than once.

  37. kcallahan Says:

    This worked for me …

    # cd /Developer/SDKs
    # sudo ln -s MacOSX10.5.sdk MacOSX10.4u.sdk

  38. Snow Leopard Issues | Content Here Says:

    […] is the problem that I struggled most with. I followed the instructions here. The compile and build worked but I could not import the library. I finally solved the problem by […]

  39. Study03.net 対シンバシ専用 Says:

    [Python][Mac] MySQL-Pythonのインストールにはまった件…

    はまった事を思い出しながら書いておく。 iMac上にPythonの開発環境を構築していて、MySQLにアクセスするための「MySQL-Python」をインストールしようとしたら、派手にエラーが出てインストールできなかったの対処法をメモ インストール pip install MySQL-Python エラー エ…

  40. 家欣的天空 » install MySQL-python on Mac OS Says:

    […] 最后原文链接 http://cd34.com/blog/programming/python/mysql-python-and-snow-leopard/ […]

  41. gawbul Says:

    Install XCode from you OSX DVD, remove any traces of MySQL as listed here (http://stevemoss.posterous.com/uninstalling-mysql-on-os-x), install the latest 64bit MySQL client and then try the following (also add them to your ~/.profile, so they load every time your open a shell).

    export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/usr/local/mysql/lib
    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/mysql/lib
    export ARCHFLAGS=”-arch x86_64″

    Then install mysql-python

  42. gawbul Says:

    Ah, you need export PATH=$PATH:/usr/local/mysql/bin as well, add that to ~/.profile too :)

Leave a Reply

You must be logged in to post a comment.

Entries (RSS) and Comments (RSS).
Cluster host: li