The colorful wolf

October 8, 2010

Windows + MySQL + Python == hell

Filed under: Tech — randy @ 23:45

At the moment I am thoroughly pissed off at MySQLDB’s lack of support for getting the library to work under Windows. The documentation even clearly states that Windows is not supported at all. I can feel the geek anger from here. As a self-respecting programmer, how can you write a library for a cross-platform scripting language that is in fact not supported on a major platform like Windows?

Anyway, after browsing around the net I found several solutions, none of which are good. Essentially the problem is that the installer doesn’t work on windows, for various reasons. I’ll list here everything you need to do to get the damn thing to work, based on the MySQLDB 1.2.3 version of the library, and the target being Python 2.6. (you can get the Python 2.5 egg of a recent version directly from the MySQLDB site).

  • You need to install MySQL server on your windows PC. The lib won’t compile if you don’t have MySQL’s header files.
  • If you’re any MySQL version that is not 5.0 then you need to change the site.cfg file in the mysqldb lib so it has the right version. The setup step might complain about a registry key missing. Just insert it manually if it doesn’t exist. Add a ‘location’ key with the value being the path to your MySQL.
  • You need to compile the damn thing, so you need a compiler. Another post I found mentions installing MS Visual Studio Express 2008 but you’re probably beter off installing Cygwin, GCC, G++ and Mingw32.
  • When building the lib, tell Python to use mingw32: setup.py build –compiler=mingw32
  • Theoretically you should now have a working MySQLDB for Python 2.6

Note that the last point says theoretically: I haven’t actually gotten to this stage yet as I realized too late that I forgot to install gcc. It’s late now and I’m going to bed.

It would be great if people could just precompile this stuff for Python 2.5/6/7 and x32/x64 and then include links to those libs on the front page of mysqldb. I guess that would be too easy.

Update: after installing gcc I still can’t get the thing to compile. If you’re planning to do things this way you’d better be prepared to edit the python scripts that do the mysqldb build. I recommend using Python 2.5 and the mysqldb egg for p2.5, which is readily available. If you really need python 2.6 or 2.7 then be prepared to suffer for it.

Update2: these distributions should work for most Windows versions. It didn’t for me, of course. I am very annoyed right now.

Final update: I installed Python 2.5 and everything went smoothly from scratch. I’m done in 10 minutes. Bleh.

 

 

 

Advertisements

3 Comments »

  1. Can’t complain if you didn’t pay for it bro. it’s open source for a reason. I’m sure if you help them out, they’ll be thrilled.

    Comment by Bert — October 9, 2010 @ 13:51 | Reply

  2. Very worthy point! The thing is, the link I added in update2 should really have solved my problems. Based on what I find on the net it solved the issue for everybody else. It seems I’m the odd one out. Funny thing is, the thing installed fine on Windows 7 x64, it’s just the WinXP 32 bit install that fails…

    Comment by rheide — October 9, 2010 @ 14:56 | Reply

  3. HI hope this helps,

    http://www.codegood.com/archives/4

    Comment by cpython — October 29, 2010 @ 16:37 | Reply


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: