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:
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:
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]