title: Python MySQL wrong architecture error
body: <p>I've been at this for some time and read many sites on the subject. suspect I have junk lying about causing this problem.  But where?</p>
  
  <p>This is the error when I import MySQLdb in python:</p>
  
  <pre><code>&gt;&gt;&gt; import MySQLdb
      /Library/Python/2.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 /Library/Python/2.6/site-packages/MySQL_python-1.2.3c1-py2.6-macosx-10.6-universal.egg/_mysql.pyc, but /Users/phoebebr/Downloads/MySQL-python-1.2.3c1 is being added to sys.path
      Traceback (most recent call last):
        File "&lt;stdin&gt;", line 1, in &lt;module&gt;
        File "MySQLdb/__init__.py", line 19, in &lt;module&gt;
          import _mysql
        File "build/bdist.macosx-10.6-universal/egg/_mysql.py", line 7, in &lt;module&gt;
        File "build/bdist.macosx-10.6-universal/egg/_mysql.py", line 6, in __bootstrap__
      ImportError: dlopen(/Users/phoebebr/.python-eggs/MySQL_python-1.2.3c1-py2.6-macosx-10.6-universal.egg-tmp/_mysql.so, 2): no suitable image found.  Did find:
          /Users/phoebebr/.python-eggs/MySQL_python-1.2.3c1-py2.6-macosx-10.6-universal.egg-tmp/_mysql.so: mach-o, but wrong architecture
  </code></pre>
  
  <p>I'm trying for 64 bit so checked here:</p>
  
  <pre><code>file $(which python)
  /usr/bin/python: Mach-O universal binary with 3 architectures
  /usr/bin/python (for architecture x86_64):  Mach-O 64-bit executable x86_64
  /usr/bin/python (for architecture i386):    Mach-O executable i386
  /usr/bin/python (for architecture ppc7400): Mach-O executable ppc
  file $(which mysql)
  /usr/local/mysql/bin/mysql: Mach-O 64-bit executable x86_64
  </code></pre>
  
  <p>Have set my default version of python to 2.6</p>
  
  <pre><code>python
  Python 2.6.1 (r261:67515, Feb 11 2010, 00:51:29) 
  [GCC 4.2.1 (Apple Inc. build 5646)] on darwin
  </code></pre>
  
  <p>Tried deleting build directory and python setup.py clean
  Renamed Python/2.5/site-packages so it could not try and pick that up.</p>
  
  <h1>UPDATE</h1>
  
  <p>Deleted everything and followed the instructions here:  <a href="https://stackoverflow.com/questions/1904039/django-mysql-on-mac-os-10-6-2-snow-leopard">Django + MySQL on Mac OS 10.6.2 Snow Leopard</a> installing using macports.  </p>
  
  <p>But basically still get the same error</p>
  
  <pre><code>Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
    File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/MySQLdb/__init__.py", line 19, in &lt;module&gt;
      import _mysql
  ImportError: dlopen(/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/_mysql.so, 2): no suitable image found.  Did find:
      /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/_mysql.so: mach-o, but wrong architecture
  &gt;&gt;&gt; 
  </code></pre>