Install 64-bit MySQLdb for Python 3 on Windows 7

Come at me MySQLdbJesus Rollerblading Christ. It all started as a simple idea: I would install Django and start working on this web app idea I had and use it as a chance to learn more about Python and Django. I also decided to go with MySQL as the database for it since I already have a MySQL server installed on my home computer from previous projects. Little did I know that since I had chosen to go with Python 3, I was in for several evenings of pain and agony dealing with MySQLdb. After an emotional rollercoaster of build path fuckery that made me want to claw my eyes out, I finally got it working: I can use MySQLdb for Python 3.2 on Windows 7 64-bit. Here’s my tale in case you find yourself in the same situation and begin to ask yourself, “Why the fuck do people put up with this?”

The Setup

Like I said, this is all because I was stupid enough to try to install Django 1.5 on Windows 7 using 64-bit Python 3.2 against a MySQL database server. FUCKIN’ N00B, HOW DARE YOU!

The first warning should’ve been that in Django’s docs they explicitly mention that the latest release of MySQLdb doesn’t support Python 3. “No problem”, I thought, “I’ve made a living off of dealing with software build bullshit, I can handle this.”

Getting Started

So I had to download a few things to get going:

  1. First I double checked the version of the MySQL server on my computer (which I had installed via Zend Server some time ago). It’s 5.1.43, so then I went hunting on MySQL’s website for a full binary + headers + libs package and found it on So I downloaded the 64-bit zip (I figured since I have 64-bit Python, but it probably didn’t matter). Then I just unpacked that zip to my C:\
  2. Next I downloaded the MySQL-for-Python-3 package the good Django folks suggested in their docs and unpacked that to a separate folder on C:\
  3. Also, I already have Visual Studio 2012 installed, so I had all the C compilers and shit at my disposal. Yay.

The Blood and Guts

After much trial and error and googling. This is what I came up with to make it work:

  1. Open up a cmd prompt
  2. Since I have Visual Studio 2012 I had to trick their (not sure if it’s Python’s or MySQLdb’s) stupid build process by pointing them to my Visual Studio 2012 toolset: SET VS90COMNTOOLS=%VS110COMNTOOLS%
  3. Then I cd’ed into the MySQL-for-Python-3 directory I unpacked earlier and edited the site.cfg (not in notepad..) file to change the mysql_location to point to the directory I unpacked the MySQL binary+header+libs package to earlier (e.g. mysql_location = C:\mysql-5.1.43-winx64)
  4. Next, I had to edit the _mysql.c file (again, not in notepad) in MySQL-for-Python-3 to change line 35 from my_config.h to config-win.h
  5. Then, I edited my Python distribution’s C:\Python32\Lib\distutils\ to add a line after line 638 (ld_args.append(‘/MANIFESTFILE:’ + temp_manifest)) as: ld_args.append(‘/MANIFEST’). Why? Cause this dude said so, and it worked.
  6. Oh yeah, and I had to edit the MySQL-for-Python-3 file to change ‘lib’ to ‘lib/opt’ on line 17’s setting of library_dirs cause otherwise it couldn’t find the goddamn MySQL libs.

And then FINALLY I was able to build and install the thing:

C:\MySQL-for-Python-3-master>python build
running build
running build_py
copying MySQLdb\ -> build\\MySQLdb
running build_ext

C:\MySQL-for-Python-3-master>python install

And it fucking worked!

Yay Django. Yay Cloud.

So yeah, I’m sure some enlightened Python god will tell me I brought this pain upon myself given my version choices (and please tell me how stupid I am for using Windows), but it’s crap like this that makes me want to run screaming and crying back into Visual Studio/C#’s warm embrace, or at least PHP’s bony grasp…

Anyway, if you’re running into similar issues trying to force MySQLdb’s square peg into Python 3’s round hole, I hope this helps.

Automation overkill?

AT&T calls. Dropped.Back in 2008 I switched my wireless service from Verizon to AT&T because I wanted an iPhone 3G. Then during my 2nd 2-year contract deal, Verizon was finally able to offer iPhones on their network. Given how crappy my AT&T 3G service was in downtown Chicago and on my train ride home through the west side. I’m in the middle of the 3rd largest city in the country, how the fsck was I still getting dropped calls?! Or faster service over AT&T’s Edge connection than over their 3G connection in the train stations?!

Anyway, so finally in February of this year I made the jump back to Verizon when it came time to upgrade to a shiny new iPhone 5. The process was smooth and painless. Then a few weeks later I got a check in the mail from AT&T. Turns out I had a credit left on my account.

Now I’m all for getting every dime of money I’m owed, especially when a company is crediting me. And on the one hand I appreciate AT&T’s thoroughness, but I can’t help but think this may have been some automated process overkill:

We're in the money!

That is not a joke. I received a check for the one penny credit left on my account with AT&T. Again, I’m happy they want to give me ALL the money I’m owed, but I can’t help wonder the cost and general resources required for them to print that check/mailing, and for the USPS to deliver it to my doorstep from whatever AT&T corporate office.

I have to assume this was just some automated program/system that noticed my account was closed and there was a credit on it, so it authorized some other system to print me out a check and have someone mail it out. Not to toot my own horn, but this whole situation made me think of an article I wrote for the windows devops site my friend and I run about applying software development best practices to devops and how automation may seem like a good idea at first, but when left unchecked, it can lead to overly complicated and sometimes completely unnecessary situations like mailing some guy a check for $0.01. I dunno, I guess I’d rather have that penny than AT&T, but Jesus Rollerblading Christ was it really worth that effort on their part?

DevOps on Windows, Windows DevOps, Windows Sysadmin

In no way affiliated with MicrosoftHere’s yet another shameless plug: this time it’s for a niche site I’ve been working on with a buddy of mine. We’re hoping to teach the world about our awesome philosophies and practices about our flavor of DevOps, in a Windows environment. Windows DevOps. Yep.

The site is called DevOps on Windows. If you’re a Windows applications developer, a Windows sysadmin, a Devopeler, or if you’re just interested in quality technology practices in general, then check it out. We have several articles up already with plenty more in the pipeline that we’ll be releasing over the next few weeks.

To quote from our About page:

To us, DevOps is the idea that software should be simple to operate. Deployments should be routine, not terrifying. Configuration should require a few clicks, not a thousand-line shell script. Problems should be easy to spot, not buried in a log file.


Our focus is on applying DevOps in a small- or medium-scale Windows enterprise environment. We want to make it clear that DevOps is not just for the Facebooks of the world, it can be the right answer for your organization as well.

So yeah, stop by the site, give it a read, let us know what you think in the comments!