Configuring Python’s Easy Install on Windows

I ran into an interesting issue with easy_install the other day. What is easy_install? Let me answer by analogy: easy_install is to Python like Gems are to Ruby. In other words, it is an apt-get like application that will automatically fetch, install and configure packages for you. So for example, you could go:

easy_install simplejson

To install a module for parsing JSON data. At least in theory the package should be fetched from some online repository, and automatically installed on my machine. Unfortunately it did not work on my windows machine. Instead I got this lovely error message:

Python was built with Visual Studio 2003; extensions must be built with a compiler than can generate compatible binaries. Visual Studio 2003 was not found on this system. If you have Cygwin installed, you can try compiling with MingW32, by passing “-c mingw32″ to setup.py.

Unfortunately I do not own Visual Studio 2003. Never had owned it, and likely I never will. I do on the other hand use Cygwin, and I do have MINGW32 installation present on my hard drive. The problem is that easy_install does not take an argument that would let me specify the compiler. I had to find another way of forcing Python to compile the packages using Mingw32 environment.

This can be done by modifying the Distutils configuration file. On Windows machines it is located in: C:\Python25\Lib\distutils\distutils.cfg. Or rather it is supposed to be located there. In my case the file did not exist in that directory so I simply created it. Inside I added the following two lines:

[build_ext]
compiler=mingw32

After this, I simply had to make sure the Mingw32 binaries were in my %Path% and I was all set. The simplejson module downloaded and installed without any issues. I’m putting this out here so that anyone having this issue can find it and resolve it the same way I did. Easy install is just to convenient not to use it on Windows.

[tags]easy_install, python, mingw32[/tags]

This entry was posted in programming and tagged . Bookmark the permalink.



5 Responses to Configuring Python’s Easy Install on Windows

  1. Mirko GERMANY Mozilla Firefox Ubuntu Linux says:

    they are offering a free version of visual studio, ‘express’.

    their IDE is the best I have tried – editor has some nice advanced features, and none of the FOSS IDEs have that good debugger integration.

    I often wonder if I am just spoiled by that IDE.

    what tools (editor / IDE) do You use for developing?

    Reply  |  Quote
  2. Luke Maciak UNITED STATES Mozilla Firefox Ubuntu Linux Terminalist says:

    The Visual Studio Express tools are great. I use the C# one whenever I do some .NET stuff. But python specifically wanted the VS 2003 version and having VS C# 2008 installed on my machine did nothing. :P

    Reply  |  Quote
  3. Starhawk UNITED STATES Mozilla Firefox Linux says:

    Interesting you know a few days ago i installed python wxwidgets and a few other things on my windows partition. Easy_install was of course one of the first things I installed. Haven’t used it, easy_install in windows yet because I spend most of my time in Ubuntu, hmm gonna have to give a try sometime soon. I probably will need this post if I have the same issue, so thanks you most likely saved me a hours worth of googling. lol

    Reply  |  Quote
  4. Luke Maciak UNITED STATES Mozilla Firefox Windows Terminalist says:

    Let me know if you run into this issue. Perhaps I just have a mutated windows machine or something. But I think this issue will pop up all across the board.

    Reply  |  Quote
  5. Alec Munro CANADA Google Chrome Windows says:

    Thanks Luke, I had been manually building packages for the last hour before I found your solution.

    Reply  |  Quote

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>