Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing PIL on Snow Leopard

Hey, i have a problem installing PIL on Snow.

I have a clean installation of macports after the upgrade to SL and installed from source the jpeg library following the OS specific installation instructions. Installing PIL with pip goes well but when i try to import the _imaging module i get the following message:

Traceback (most recent call last):
File "<string>", line 1, in <module> ImportError: dlopen(/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PIL/_imaging.so, 2): no suitable image found. Did find: /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/PIL/_imaging.so: mach-o, but wrong architecture

like image 350
0xbadbeef Avatar asked Feb 28 '10 23:02

0xbadbeef


3 Answers

MacPorts already has a PIL port that will do all the work for you!

sudo port install py26-pil

You should first go into the site-packages directory and elsewhere to remove the stuff you installed manually, though. MacPorts will install all the necessary dependent libraries.

like image 158
Ned Deily Avatar answered Nov 14 '22 23:11

Ned Deily


PIL on Mac OS X has been a pain point for many of my friends. These instructions seem to often help speedup the enlightenment process:

http://passingcuriosity.com/2009/installing-pil-on-mac-os-x-leopard/

Good luck!

like image 33
pithyless Avatar answered Nov 14 '22 22:11

pithyless


I had the same problems, and actually created a small tutorial on how to resolve this. getting a working copy of PIL, libjpeg and Imaging on Snow Leopard or even Lion

My default version of Python was still on 2.6 so I had to switch to 2.7

defaults write com.apple.versioner.python Version 2.7

get v8c of jpeg cd into jpeg directory.

sudo make clean
CC="gcc -arch i386" ./configure --enable-shared --enable-static
make
sudo make install

get imaging i am using 1.1.6

untar cd into imaging

sudo rm -rf build
vi setup.py
JPEG_ROOT = libinclude(“/usr/local/lib”)
sudo python setup.py install

And it’s that simple

Run your python interpreter,

import PIL
import _imaging
import Image

if all is well, then your all set.

like image 1
ApPeL Avatar answered Nov 14 '22 22:11

ApPeL