Installing PIL on Snow Leopard — NOTHING WORKS

我的梦境 提交于 2019-12-06 00:22:32

I recently wrote an article on how to get PIL, django, libjpeg to work nicely alongside Snow Leopard

http://appelfreelance.com/2010/06/libjpeg-pil-snow-leopard-python2-6-_jpeg_resync_to_restart/

I'll copy it in here for you too.

If you don’t have this download it first.

http://www.ijg.org/files/jpegsrc.v7.tar.gz

go into your shell environment and untar by running the following

tar -zxvf jpegsrc.v7.tar.gz
cd jpeg-7

then run

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

Next get PIL and untar it

http://effbot.org/downloads/Imaging-1.1.6.tar.gz
tar -zxvf Imaging-1.1.6.tar.gz
cd Imaging-1.1.6

If you already have PIL I would recommend running

sudo rm -Rf build

to clean any existing builds, this has caused me loads of errors and gray hairs!

in your settings.py file run find JPEG_ROOT

amend it so it looks as follows

JPEG_ROOT = libinclude(“/usr/local”)

Next move onto the build

sudo python setup.py build

if libjpeg is successfully installed you should be able to run python selftest.py without any errors relating to “jpeg”

sudo python setup.py install

if all has worked successfully you should be able to enter your python interpreter by executing python in your command line and also do the following:

import PIL
import Image
import _imaging

without any errors.

Just to triple check I have a simple jpeg on my desktop.

image = Image.open(“/Users/MyName/Desktop/myimage.jpeg”)
image.save(“/Users/MyName/Desktop/test.jpeg”)

should work without errors

Download macport:

http://www.macports.org/install.php

Then use it for pil:

http://trac.macports.org/browser/trunk/dports/python/py-pil/Portfile

I also had a lot of trouble with this, but port managed.

I've always gotten several screens worth of gcc errors when trying to install PIL. At some point I got something working (perhaps via MacPorts), so now my solution is to copy it to the appropriate site-packages (e.g. inside a new virtualenv).

I just posted it here: http://blogmaker.com/PIL-1.1.6-for-MacOSX-10.5-Leopard.zip

Works for me; I have no idea whether it will work for anyone else! Feel free to contact me with suggestions. And, let me know if there's a better place I should post it. PIL is both very cool and a royal hassle; it would be nice to have a definitive place for support. There are other PIL-related issues that I never solved.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!