views:

593

answers:

1

I've been happily using Django and MySQL in development on an existing machine running OS X 10.4 Tiger, and have set up a similar environment in 10.5 Leopard on a new 64-bit MacBook, with a working MySQL and Python 2.6.4.

However, now I want them to communicate, easy_install MySQL-python gave ld warnings that the file is not of the required architecture, which led me to test my Python 2.4.6 install (from the Mac OS X disc image):

>>> import sys
>>> sys.maxint
2147483647

Ah. So my Python install appears to be 32-bit and (I think?) won't install MySQL-python for my 64-bit MySQL. There are lots of hacks out there for MySQL-python on OS X (mostly 1.2.2), but - after hours of reading - I'm pretty sure they won't fix this architecture mismatch. So I'm stuck because I can't decide whether to:

  • give up, remove the 64-bit MySQL install (thorough methods, please?) and use the 32-bit MySQL disc image instead;
  • re-install Python in 64-bit mode from the tarball,
    --with-universal archs-64-bit and --enable-universalsdk=
    as detailed in Python.org's 2.6 news.

So my questions for anyone who has encountered this issue are:

  1. Is installing 64-bit Python on OS X 10.5 worth bothering with?
  2. If so, (naive, lazy question!) how are the two required arguments combined?
  3. If I just skip along in 32-bit (as on my working setup) what am I missing?

I'm after a hassle-free install that's easy to reproduce on other machines (possible student use) so I'd really welcome your opinions, please!

A: 

I'm posting this here in case anyone finds this page and needs an answer...

Solution: remove the MySQL 64-bit install (change the below to match your MySQL version number):

cd /usr/local
sudo rm -rf mysql-5.1.41-osx10.5-x86_64
rm -r mysql
cd /Library/Receipts/
rm -r mysql-5.1.41-osx10.5-x86_64.pkg

Install the latest 32-bit MySQL package from the downloads page and set it up as required.

Remove MySQL-python with:

easy_install -m MySQL-python

Then delete the egg in site-packages and make sure easy_install -m removed the package line in the easy-install.pth file there.

Start up MySQL, then re-install MySQL-python (make sure you get the latest version - 1.2.3 - at time of writing): easy_install MySQL-python

Test it:

>>> import MySQLdb

For me, that solved the problem. No need to edit _mysql.c (as advised for MySQL-python 1.2.2) or mess with any other settings.

Should you need them (if the above fails, or if you really want to try a 64-bit install), here are some of the links used while researching this:

But note this:

"if you go 64, then you will have to recompile every single thing that interacts with python, mysql and apache to work as a 64 bit arch program"

And for anyone on Snow Leopard:

Finally, the MacPython 2.7 installer now covers 64 bit. See this post for the differences between running 64 and/or 32 bit.

Dave Everitt