Friday, May 13, 2011

Installing PIL with jpeg and freetype support on mac osx with virtualenv, homebrew and pip

When attempting jpeg modifications in python after having done the obvious "pip install PIL", then I get an IOError with the message "encoder jpeg not available" or maybe "decoder jpeg not available".

Because there are so many different ways to install PIL, finding how to fix error on the web is not easy. This post is to help me and others of us who use and enjoy virtualenv, homebrew and pip.

1. Ensure Xcode is installed. Upgrading to OSX 10.7 Lion removes Xcode
2. brew install jpeg
3. workon {your virtual env} # using virtualenvwrapper
4. if reinstalling: pip uninstall PIL
5. pip install --no-install PIL

6. edit setup.py in {your virtual env dir}/build/PIL

***setup.py*** - also showing freetype and little cms if needed
*snip*
JPEG_ROOT = libinclude("{homebrew install absolute dir}/Cellar/jpeg/8c")
FREETYPE_ROOT = libinclude('/usr/X11')
*snip*

7. save and close setup.py
8. pip install PIL

Tuesday, September 2, 2008

Python and Django

I have been trying out some of the new web development frameworks, and have formed some thoughts and opinions of them. Of the web development frameworks, I tried Ruby on Rails (RoR), then Groovy/Grails, and now Python/Django.

RoR seems nice, but doesn't have a great reputation for scaling up. Plus, Ruby is a complicated language. Grails didn't have a good community or good documentation, and after trying Django, I realize that it's slow. Grails is made by mixing a bunch of proven frameworks rather than creating a framework from the ground up. That could be viewed as a good thing, but maybe that's what made it slow.

After trying both RoR and Groovy/Grails I realized that even though the frameworks are made to be simple, I'm not going to be able to do much in the frameworks unless I learn the language that they use. That's what made me decide to try Python/Django. Based on my reading on the internet, it seems that Python is a popular language with good libraries. It's also more intuitive to me than Ruby. I understand that Python is a popular dynamic programming language for experienced Java programmers, which is what I am.

When I was trying to learn RoR, I bought a RoR book. The book was hard to follow, because it used an older version of the framework than what I downloaded to my machine. In addition, it wasn't much more helpful than the tutorials on the internet, so I returned the book. Since trying Python/Django I realized that the framework is less of an issue than learning the language, so I bought "Learning Python". I'm attempting to read the book cover-to-cover, which I've never done before with a programming book. I must be excited about it.

So far I like Python, and I think it will take me into the world of dynamically typed languages from statically typed (Java). Hopefully, it will make me a better programmer.

Friday, August 1, 2008

The search for a great web development framework - Part 1 - Ruby on Rails, Grails, and Django

The first time I started doing web programming, I was using java struts and straight JDBC. I had just learned object oriented programming, and was excited to put it to use. However, I immediately became annoyed with the difficulty in working with relational databases and OO code. However, I was still excited about OO programming. Shortly thereafter, I took a role developing Eclipse plugins. As part of that work, I was exposed to the Eclipse Modeling Framework. To my great pleasure, with that framework I was able to persist objects with little work on my part.

Due to my enterprise development role becoming boring in the technical sense, I have become inspired to see what the latest and greatest there is in programming. I have also been considering doing some freelancing, which would mean I would most likely be doing some web programming. I was told some things about Ruby on Rails that sounded interesting to me. Again, especially the part about persisting objects in the database is very easy.

So far, I have tried Ruby on Rails, and Grails, and I have been looking into Django. Here are my thoughts...

Ruby on Rails is cool, but seems to have a reputation for not scaling.

I started looking into Grails because of it being really a java technology. Most of my experience is in java, and java has such huge, mature libraries because it is so widely used. After attempting Grails I found that the documentation was not good, it was slower than RoR, I didn't like having to restart the server when I changed my code when I didn't have to with RoR, and doesn't seem to have a real strong community.

I'm thinking about trying Python/Django. Python seems to have a strong community of programmers and I've heard the libraries are good like Java.

Thursday, July 31, 2008

Why is Ubuntu better than Windows?

My wife asked me "Why is Ubuntu better than Windows? And why is it just starting to "catch on"? Hasn't it been around for a while?"

Some may argue that Ubuntu is better than Windows, or that anything linux is better than Windows. Whatever, I don't know enough about either to say that. However, Ubuntu is FREE, and claims that it always will be! I probably spent 8 hours trying to get Ubuntu working on an old Windows machine. That's annoying, but it's really not to bad considering that there's a sticker on my laptop that says "Designed for Windows".

There are other linux distributions, but Ubuntu's goal is to be easy to use, and they seem to have the funding and interest to make that happen. My wife also asked me why it hasn't caught on even though it's been around for a while. It has been around for a while, but it has improved. That is also why it's just starting to catch on. It's improved enough that more dummys are able to use it.

Wife didn't ask this, but the main reasons that I am interested in Ubuntu is that linux is a highly respected OS (popular with computer geeks), and it's FREE!