Attempting to compile mysql-python

The other day I mentioned that I’d like to be able to use mysql-python with Python 2.5 on Windows. It turns out that this is no small task.

After some hunting around, it looks like mysql-python has fallen into a state of being poorly maintained and development is now limited to “one dude who no longer uses Windows.” Thus, no Windows releases should be expected in the near future.

Tonight I took a quick look at what is required to compile it myself. It turns out that that too is no small task…


I first downloaded the source package from SourceForge and unpacked it. I quick attempt to build gave me my first error:

C:\...\...> python setup.py build ... running build_ext building '_mysql' extension error: Python was built with Visual Studio version 7.1, and extensions need to be built with the same version of the compiler, but it isn't installed.

Ok, so I need Visual Studio 7.1 (2003). That shouldn’t be hard to get, right? Well it turns out that although you can get Visual Studio Express 2005 from Microsoft for free (with registration) that version won’t work. Here’s a note from a similar issue that shows up in 4Suite:

Note that Microsoft have withdrawn the free MS Toolkit Compiler, so this can no longer be considered a supported option. The instructions are still correct, but you need to already have a copy of the compiler in order to use them. Microsoft now supply Visual C++ 2005 Express Edition for free, but this is NOT compatible with Visual C++ 7.1 (it uses a different C runtime), and so cannot be used to build a version of 4Suite compatible with the standard python.org build.

My next attempt was to use MinGW to get it to compile.

I downloaded the installer package from SourceForge and got it loaded. I also made sure that I added C:\mingw\bin to my PATH and restarted my console. The GCC executable seemed to work fine, so I edited the setup.cfg file in the mysql-python source to include the following:

[build] compiler=mingw32

And then attempted to compile, this time with the following command:

python setup.py build -c mingw32

This time it seemed to compile some of the files, but then failed with the following error:

_mysql.c:2808:31: too many decimal points in number error: command 'gcc' failed with exit status 1

Here’s the _mysql.c code at lines 2807 - 2809:

if (PyDict_SetItemString(dict, "__version__", PyString_FromString(__version__))) goto error;

Unfortunately Google only has about 109 hits for that error, and I was at a dead end.

Any ideas?

Related: No MySQL for Python 2.5 on Windows?

Update: Yes, I know I can either switch to Linux on my desktop or I can use PostgeSQL instead. But that’s not what I want to do.

5 Responses to “Attempting to compile mysql-python”

  1. João C. Morais Says:

    Post the line.

  2. John Says:

    Heh, I guess it would be helpful if I posted the code that caused the error. :)

    I’ve updated the post (see above). Thanks for pointing that out!

  3. John Says:

    @João:

    Any ideas?

  4. João C. Morais Says:

    Have you tried using the trunk version?

  5. import this. » Blog Archive » PyCon mysql-python sprint Says:

    [...] Attempting to compile mysql-python [...]

Leave a Reply