Installing PIL inside virtualenv for Ubuntu 9.10

2010-03-31 3 min read Django Python Eddie

I just removed a (real live) bat from my living room. That was easier than installing PIL in a virtualenv for Ubuntu 9.10. Why? Googling the subject seems to bring up a lot of old or mis-information. This will explain how… mostly so I can do it again next time.

I started with a –no-site-packages virtualenv, so as not to use (or more importantly depend) on any of the global site-packages. Ok, cool.

$ virtualenv --no-site-packages myEnv

First, I needed to install the python developer tools. (Use apt-get or aptitude, whatever floats your boat)

$ sudo aptitude install python-dev

Then, I needed to install libjpeg and libjpeg-dev. I’m not sure why, but I needed libjpeg simply doesn’t exist, so I needed to install libjpeg62. I can’t pretend that I know the difference (or if there is one). In fact, I may have gotten away with installing libjpeg62 and libjpeg-dev (rather than both “62” versions… libjpeg62 and libjpeg62-dev), but only further testing will tell.

Why? If you install PIL without this library, you’ll get those wonderful “decoder jpeg not available” messages in Python. Or worse yet, if you’re trying to use it in a Django, you may get some errors (specifically the “Upload a valid image. The file you uploaded was either not an image or a corrupted image” warning), or you may not get any until you open the shell. Either way, you can test with the method listed below. If you get the “decoder jpeg not available” message, your install didn’t work.

The zlib package handles PNGs.

$ sudo aptitude install libjpeg62 libjpeg62-dev $ sudo aptitude install zlib1g-dev $ sudo aptitude install libfreetype6 libfreetype6-dev

Alright, now we seem to be done with the prerequisites. Start your virtualenv (of course, myEnv in the example is the name of your virtualenv).

$ source myEnv/bin/activate

Download PIL and install. This will make sure to install PIL within your virtualenv’s site-packages.

(myEnv)$ wget http://effbot.org/downloads/Imaging-1.1.7.tar.gz (myEnv)$ tar zxvf Imaging-1.1.7.tar.gz (myEnv)$ cd Imaging-1.1.7 (myEnv)$ python setup.py install

If you run into further problems (the “decoder jpeg not available” message again), you may have to resort to the long directions to get PIL and libjpeg to play happily together, but I hope not.

Now that you have everything installed, test it. Open up a python shell from within your virtualenv.

(myEnv)$ python

Now try the following (with an image in your home directory) to see if everything is running smoothly.

Continue reading

Review of Learning jQuery 1.3

2009-09-24 2 min read Uncategorized Eddie

Learning jQuery 1.3 Cover
Learning jQuery 1.3
There were many things to like about this book Learning jQuery 1.3 by Jonathan Chaffer and Karl Swedberg. The stand-out positive in my mind is the wealth of topics covered. Both simple and difficult concepts are included, and both are handled with ease. Good coding habits are repeatedly mentioned throughout. Subjects like progressive enhancement are encouraged, and pitfalls like memory leaks are warned against. Many real-world examples are included, as well as the full source code.

Learning jQuery 1.3 has a writing style that is very dry for a book written in a semi-conversational voice. I prefer a writing style with a little more personality to it, but acknowledge that’s not for everyone.

I did have two small complaints. First, I like to see the API list out at the top of the chapters. Appendix D contains a complete reference, but I like having a list of methods to be covered at the beginning of the chapter. While I’m at it, I may mention that the “complete” reference is little more than a cheetsheet style list. Perhaps a little more would have been useful.

My second complaint is about the poor code syntax highlighting. Just for record, this has nothing to do with the content, it’s just a complaint against the publisher. Take page 145, where three-quarters of the page is example code, but contains only bold line at the top showing the emphasized line. First, the bold often wasn’t enough to draw the eye… especially at the beginning of the book when a novice reader has to mentally separate standard JavaScript from jQuery code. Second, I understand that the example code is included, but couldn’t it have simply been excerpted here? I don’t understand wasting an entire page, when much less would do.

Based on the overall quality of the book, I recommend it for jQuery beginners.

Boring "I moved" post

2009-09-09 1 min read Personal Eddie

Summer was ending so I decided to move. Ok, not really, it was simply time.

I’ve moved back to my parent’s house in Laurel, MD… which is exceptionally close to Columbia, MD. I’ve moved into my parents house in an attempt to save some money, I want to clean it and restore it, while putting my would-be rent money into the property taxes here.

The move wasn’t difficult in and of itself, but tied with the work that needed (and still needs) to be done at the house, it has been quite an undertaking. I have so much to do it’s quite overwhelming.

All of that mess aside, I am looking forward to getting back to study.

Bad chain tool, bad

2009-08-12 1 min read Bikes Personal Eddie

Finally got the cranks on, the pedals on, the new 17 tooth cog on the old wheel that I re-tensioned and trued (well, partially trued at least), only to put the chain on with a broken chain tool. (I didn’t realize it was broken). So one of the bushings became bent, and on my ride home, I popped the chain. Tried to use alternate links to fix it, but they stuck (and ended up with only slightly bent bushings). So a new chain it is for me, unfortunately.

Older posts Newer posts