

If you're on any sort of modern Mac, it's going to use the x86_64 support. You might think this makes things easier, but it does not.
#MAC PYTHON INSTALL MYSQL CODE#
For example, the Python Apple distributes in Snow Leopard is a fat binary that includes code for PPC, i386, and x86_64. We can safely ignore Motorola since Apple hasn't used them in a very long time, and PowerPC can be mostly ignored, but you still see some support for it. The hard part about the Mac is, there are three architectures you could be building for: PowerPC, Intel 32-bit, and Intel 64-bit. If Homebrew has a "formula", I can't find it, but a pip install should work once you have compatible versions of Python and MySQL. MacPorts has a port for MySQLdb (py-mysql and variants). Once upon a time, everything in MacPorts had to be built from sources, like a *BSD or Gentoo-style port system, but there are now binary packages for many things. The simple part is: You need Xcode, which is Apple's compiler toolchain.īy far the easiest way to get MySQLdb on the Mac is to use one of the two major UNIX-ish package distributions: MacPorts or Homebrew.
#MAC PYTHON INSTALL MYSQL MAC OS X#
Mac OS X is very POSIX-like inside, and it so MySQLdb's setup treats it as POSIX, but it can get complicated. Hey, if you're using FreeBSD or another *BSD, or Solaris, you probably don't need my help to install it. MySQLdb has been a FreeBSD port for 12 years. For Ubuntu (and probably Debian):Īpt-get install build-essential python-dev libmysqlclient-dev Each Linux distribution has packages for all the prerequisites, but the names of these packages vary. But what if you can't, and you really do need to build your own? Install using pip.


If you are a Linux user, I recommend you use your distributions packages. Over time, several Linux distributions (Red Hat, Debian, Ubuntu, etc.) picked it up, created their own packages, and distributed them. MySQLdb was originally developed specifically for use on Linux, as it was the only platform I cared about at the time. MySQL development headers and libraries.Python development headers and libraries.Since MySQLdb uses a C module to link against MySQL's client library, you will need: With the latest version, most of the time, you can run:Īnd you're done.
