Sunday, May 10, 2009

Failed to build these modules: binascii zlib

It's very rare that I encounter a computer problem that I can't solve. I thrive on the challenge of rooting out the cause of an obscure error and finally getting my software to run properly. However, I thought I had been defeated by the error in the title of this post.

The trouble started when I tried to install Django on my Ubuntu Intrepid Ibex partition. I was unaware of the convenient apt-get method of installation, so I was going through Django's long list of dependencies, trying to find the initial critical library on which the entire list depended. I thought I had reached the end of the chain with Flup, a WSGI (Web Server Gateway Interface) library for Python. I tried to install it from its Python egg, but it threw several serious errors that indicated that I didn't have the necessary library to "hatch" the egg.

Of course, I found the required library and downloaded it, only to realize that it, too, was contained within a Python egg. The readme file clearly indicated that I could install the software by running a simple command: python [I forgot the name of the file].egg. Every time I tried, it would tell me that zlib wasn't installed and quit.

Of course, I looked up the "missing zlib" error and found some possible solutions. I tried to install the zlib python module from source and tried to download it from the repositories, but nothing would stop the fatal error.

I gave up.

Because my school work started to pick up, I didn't really have time to think about Ubuntu and my installation woes for about a month. The trouble started again as I was preparing for one of my Google Summer of Code proposals. When I attempted to install PGReloaded, an unstable development branch of the PyGame multimedia library, on my Intrepid Ibex partition, I encountered strange error after strange error, and I was completely unable to install the library. I thought that the problem might be related to my installation-from-source procedure, so I tried to install the standard Pygame library through apt-get and play a game that relied on it. The game couldn't find Pygame, even though I had just installed it.

I then remembered that installing Python 2.6 had given me an installation error: "Failed to build these modules: binascii zlib." I realized all my problems were caused by a faulty Python installation. First, I tried to verify the integrity of my Python installation. I checked md5 sums, ran tests, and reinstalled Python 2.6 from source. All the tests failed due to the absence of binascii and zlib. Looking for a fix, I started googling around, this time for Python installation message.

I found only one other instance of my problem in a post on a mailing list; unfortunately, the poster didn't get an answer. I thought that the gurus on the Python Help mailing list might be able to diagnose my problem and find a solution. Unfortunately, I hit a dead end there, too.

Now, the narrative flies off the tracks. If you want to read the whole convoluted tale and you have a taste for debugging narratives, you can take a look at Jaunty Jackalope released: Vista all over again. To summarize, I had to reinstall Intrepid Ibex and destroy all my files after an ill-advised "upgrade" to Jaunty Jackalope. I had to start from scratch.

Researching an entirely different problem, I stumbled across this Python 2.6 on Intrepid Ibex installation guide. Apparently, all my problems were caused by a conflict between the system default Python installation, 2.5, and the newer version, 2.6. I was thrilled to finally have my answer, but I wasn't looking forward to another lengthy, complex Python installation.

In the end, after a little advice from some python gurus, I decided to skip Python 2.6 entirely and stick with good ol' 2.5. This time, PGReloaded installed easily (for an unstable development library), and I don't expect any problems installing Django. I guess the moral of this story is "If a task becomes incredibly difficult, make sure that it's actually worth your time."