MySQLdb installed from pypm doesn't work with 32-bit python on Mac OSX
Question: Before proceeding further, here are some details of my Mac and the installed
python (ActivePython) and wxpython versions:

_**Mac version: 10.6.6 Python version: 2.7.1 (ActiveState Python) wxPython
version: wxPython2.8-osx-unicode-py2.7_**

Here is a small code that I wrote to test:

    
    
    #! /usr/bin/env arch -i386 /usr/local/bin/python
    
    import time
    import random
    import re
    import wx
    from wx.lib.mixins.listctrl import ListCtrlAutoWidthMixin
    import serial
    import itertools
    import datetime
    import sys
    import os
    import MySQLdb
    
    print "Hello World"
    

Here is the error that I got from running it:

    
    
    Traceback (most recent call last):
      File "./sar.pyw", line 13, in <module>
        import MySQLdb
      File "/Users/ven/Library/Python/2.7/lib/python/site-packages/MySQLdb/__init__.py", line 19, in <module>
        import _mysql
    ImportError: dlopen(/Users/ven/Library/Python/2.7/lib/python/site-packages/_mysql.so, 2): Symbol not found: _mysql_affected_rows
      Referenced from: /Users/ven/Library/Python/2.7/lib/python/site-packages/_mysql.so
      Expected in: flat namespace
     in /Users/ven/Library/Python/2.7/lib/python/site-packages/_mysql.so
    

As you can see I am using 32-bit python in the shebang line because I need to
work with [wxpython](http://code.activestate.com/pypm/wxpython/) which runs
only on 32-bit. Now, the only package that has problem with the 32-bit python
is the [MySQLdb](http://code.activestate.com/pypm/mysql-python/) which has
been installed using:

    
    
    pypm install mysql-python
    

If I just removed the line

    
    
    import MySQLdb

from the above piece of code, it runs perfectly and prints "Hello World".

If I removed "arch -i386" from the shebang line, the wxpython package doesn't
work. I want to use both wxpython and MySQLdb at the same time. How do I do
it?


Answer: [Duplicate](http://community.activestate.com/node/6641) ;-)

This is a [known bug](http://bugs.activestate.com/show_bug.cgi?id=87704) \--
the `mysql-python` package is built only for 64-bit at the moment.

> I want to use both wxpython and MySQLdb at the same time. How do I do it?

wxPython 2.8 doesn't support 64-bit (due to using Carbon), this is why the
PyPM package is built for only 32-bit. You could try using wxPython 2.9.

**Workaround** : remove wxpython using pypm (`pypm uninstall wxpython`), and
then install the development cocoa binary `wxPython2.9-osx-cocoa-py2.7` from
[wxpython.org](http://wxpython.org/download.php#unstable).

