Archive

Archive for August, 2011

Easy solution to installing Python Imaging Library on a Macintosh

August 10th, 2011 Comments off

To make it easier for our customers to extract images out of PDF files without using our cloud-based PDF conversion process, I decided to investigate the use of the Python Image Library to build a utility program.

After downloading the source code, I tried to build it and soon ran into errors such as the following:

lipo: can't open input file: /var/folders/.........(No such file or directory)
error: command 'gcc' failed with exit status 1

or

lipo: can't open input file: /var/tmp//ccptvQXL.out (No such file or directory)

Turns out this was happening because my system doesn’t have the ppc binaries (nor do I want them) and one of the options being passed to the gcc compiler is

 -arch ppc

I looked around on the web and found a few pages that described this error.

E.g.,

http://www.p16blog.com/p16/2008/05/appengine-installing-pil-on-os-x-1053.html
and
http://passingcuriosity.com/2009/installing-pil-on-mac-os-x-leopard/ and
http://www.kelvinwong.ca/tag/python-imaging-library/

However, the suggested solutions were all rather painful or awkward. I decided to trace into the setup.py file to see from where it was getting the compiler options. To cut a long story short, I discovered very quickly that there’s an environment variable called ARCHFLAGS and if that is defined, then it is used before other mechanisms.

So I simply typed the following into the terminal window

export ARCHTYPES="-arch i386 -arch x86_64"
python setup.py install

and everything just built and installed with no problem whatsoever.

If you do this kind of thing often, it might be worth setting the environment value in your .bash_rc or .profile

Categories: Software Development Tags: