在Mac OS X上安装PIL以与Django一起使用

时间:2021-05-25 18:20:51

I'm really annoyed by installation of PIL (Python Imaging Library) on Mac OS X 10.6. Does anyone have it installed and could post the recipe here? I've tried a lot of them posted here on this site and a lot from google, but always anding with missing some part and can't work normally with PIL...

我对在Mac OS X 10.6上安装PIL(Python Imaging Library)感到非常恼火。有没有人安装它并可以在这里发布食谱?我已经尝试了很多这些在这个网站上发布了很多来自谷歌,但总是和缺少一些部分并且无法正常使用PIL ......

Thanks in advance. Ignas

提前致谢。 Ignas

9 个解决方案

#1


12  

EDIT: This answer has been getting voted up recently, and I want to modify it to reflect what I'm doing now.

编辑:这个答案最近已被投票,我想修改它以反映我现在正在做的事情。

Firstly, I've switched from MacPorts to Homebrew for package management on Mac OS X. Secondly, I've switched from using my package manager to using pip and virtualenvwrapper to manage my Python libraries.

首先,我已经从MacPorts切换到Homebrew以便在Mac OS X上进行包管理。其次,我已经从使用我的包管理器切换到使用pip和virtualenvwrapper来管理我的Python库。

Why I switched:

为什么我切换:

At first, with just a few Django projects, it was very easy to keep everything up to date using MacPorts. It was also fairly easy to have multiple versions of Python using python_select. What I didn't realize was that I was doing a pretty terrible job of keeping multiple libraries working side-by-side. It became obvious as I upgraded my packages that sometimes I really didn't want a project's Django version to change. After a couple of Django 1.1 projects (now running Django 1.3) started exhibiting weird behaviour (forms failing to submit because of CSRF middleware changes, small differences in Django libraries, admin app assets changing, and so on) it became clear that I should look into a better solution.

首先,只需几个Django项目,就可以很容易地使用MacPorts保持最新状态。使用python_select创建多个版本的Python也相当容易。我没有意识到的是,我正在做一个非常糟糕的工作,让多个库并排工作。很明显,当我升级我的软件包时,有时候我真的不希望项目的Django版本发生变化。在几个Django 1.1项目(现在运行Django 1.3)之后开始表现出奇怪的行为(由于CSRF中间件更改,Django库中的小差异,管理应用程序资产更改等等而无法提交表单),很明显我应该看一下进入更好的解决方案。

What I do now:

我现在应该做什么:

On Mac OS X I'm moved over to using pip and virtualenvwrapper. First off, I install virtualenvwrapper:

在Mac OS X上,我转而使用pip和virtualenvwrapper。首先,我安装virtualenvwrapper:

pip install virtualenvwrapper

This will grab virtualenv and virtualenvwrapper. You then need to add the following to your .bashrc or .profile and source it or open a new shell.

这将抓住virtualenv和virtualenvwrapper。然后,您需要将以下内容添加到.bashrc或.profile并获取它或打开一个新shell。

export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh # where Homebrew places it
export VIRTUALENVWRAPPER_VIRTUALENV_ARGS='--no-site-packages' # optional

Line 1 sets up the variable workon needs to find its files. Line 2 points to the main shell script (the path here is where Homebrew places the file, it might be different if you're using another package manager). Line 3 is optional, but I really like it: it makes sure that no currently installed libraries in the "main" site-packages repository will leak into your newly created virtual environment. I find this keeps things clean and leads to fewer surprises down the road as things are upgraded.

第1行设置变量workon需要查找其文件。第2行指向主shell脚本(此处的路径是Homebrew放置文件的位置,如果您使用另一个包管理器,它可能会有所不同)。第3行是可选的,但我非常喜欢它:它确保“main”site-packages存储库中当前安装的库不会泄漏到新创建的虚拟环境中。我发现这样可以保持物品清洁,并且随着物品升级,可以减少意外情况。

The next step is to create a new virtual environment:

下一步是创建一个新的虚拟环境:

mkvirtualenv testEnvironmentName

After making the environment, you'll be placed into it. If you kept the --no-site-packages flag, you can type pip freeze to see that your Python library slate is now blank. To escape from the virtual environment, use the deactivate command. To get into your virtualenv again, use workon testEnvironmentName. Note that you can use tab completion on the name of the environment. Also note that typing workon by itself will give you a list of available environments. From here you can pip install any libraries you want, including PIL.

在创造环境之后,你将被置于其中。如果保留了--no-site-packages标志,则可以键入pip freeze以查看您的Python库平板现在是空白的。要退出虚拟环境,请使用deactivate命令。要再次进入virtualenv,请使用workon testEnvironmentName。请注意,您可以在环境名称上使用Tab键完成。另请注意,单独输入workon将为您提供可用环境的列表。从这里你可以pip安装你想要的任何库,包括PIL。

To learn more about virtualenvwrapper, I recommend checking out the documentation.

要了解有关virtualenvwrapper的更多信息,我建议您查看文档。

Here's another great resource which taught me a lot about using virtualenvwrapper (or just view the screencast)

这是另一个很好的资源,它教会了我很多关于使用virtualenvwrapper(或只是查看截屏视频)


ORIGINAL:

原版的:

You can also instal PIL using MacPorts. The package name is py-pil. Here's more information on the package. I'm pretty fond of MacPorts over pip, as I find it gives me a bit more configurability when it comes to keeping several versions of python and several libraries installed.

您也可以使用MacPorts安装PIL。包名称是py-pil。以下是有关该软件包的更多信息。我非常喜欢MacPorts over pip,因为我发现它在保持几个版本的python和几个库的安装方面给了我更多的可配置性。

Here are the installation instructions for MacPorts: http://www.macports.org/install.php

以下是MacPorts的安装说明:http://www.macports.org/install.php

See also: What is the most compatible way to install python modules on a Mac?

另请参阅:在Mac上安装python模块最兼容的方法是什么?

#2


14  

Following steps worked for me:

以下步骤对我有用:

$ brew install pip
$ export ARCHFLAGS="-arch i386 -arch x86_64"
$ pip install pil

#3


6  

Yes, I have issues with PIL on 10.6.6 too, homebrew and easy_install.

是的,我在10.6.6上也有PIL问题,自制软件和easy_install。

The easiest solution for me was to easy_install PIL / pip install PIL, navigate to /Library/Python/2.6/site-packages/, and symlink the PIL-1.1.7-.....egg file to PIL

对我来说最简单的解决方案是easy_install PIL / pip install PIL,导航到/Library/Python/2.6/site-packages/,并将PIL-1.1.7 -... egg文件符号链接到PIL

ln -s PIL-................egg PIL


>>> import PIL
>>> from PIL import Image
# no more problems.

Edit: These days, I try to use Pillow, a library built to help install PIL. Try pip install pillow - can't hurt!

编辑:这些天,我尝试使用Pillow,一个帮助安装PIL的库。试试pip安装枕头 - 不能伤害!

#4


5  

It might be easier to pinpoint your issue if you can elaborate on what you tried and what error messages were generated with those attempts. Here's some probable solutions that you may or may not have attempted:

如果您可以详细说明您尝试过的内容以及这些尝试生成的错误消息,则可能更容易查明您的问题。以下是您可能尝试过或未尝试过的一些可能的解决方案:

pip install pil

if you dont have pip, try

如果你没有pip,试试吧

easy_install pil

Since you're on the Mac, you can also get HomeBrew (a package manager) and then try

既然你在Mac上,你也可以获得HomeBrew(包管理器),然后尝试

brew install pil

or Macports has a PIL package here.

或者Macports在这里有一个PIL包。

Or build from source?

或者从源码构建?

More importantly, the PIL README states,

更重要的是,PIL README说明,

*--------------------------------------------------------------------

* ------------------------------------------------- -------------------

Additional notes for Mac OS X

On Mac OS X you will usually install additional software such as libjpeg or freetype with the "fink" tool, and then it ends up in "/sw". If you have installed the libraries elsewhere, you may have to tweak the "setup.py" file before building.*

在Mac OS X上,您通常会使用“fink”工具安装其他软件,如libjpeg或freetype,然后以“/ sw”结尾。如果您已在其他地方安装了库,则可能需要在构建之前调整“setup.py”文件。*

That could be your issue. Good luck!

那可能是你的问题。祝你好运!

#5


2  

After fresh OS installation tried these steps:

在新的操作系统安装后尝试以下步骤

  1. Installed homebrew
  2. 安装自制软件
  3. brew install libjpeg
  4. brew安装libjpeg
  5. brew install pil
  6. 酿造安装
  7. easy_install pil
  8. easy_install pil
  9. cd /Library/Python/2.6/site-packages
  10. cd /Library/Python/2.6/site-packages
  11. ln -s /usr/local/Cellar/pil/1.1.7/lib/python2.6/site-packages/PIL PIL
  12. ln -s /usr/local/Cellar/pil/1.1.7/lib/python2.6/site-packages/PIL PIL

After that I was able to load and save jpeg files... I know that this issue has a lot of different solutions and I'm not 100% my way will work for other, but it's worth to try if you just bumping your head in to the wall :)

之后,我能够加载并保存jpeg文件...我知道这个问题有很多不同的解决方案,我不是100%我的方式会为其他人工作,但是如果你只是碰到头脑,那就值得尝试一下在墙上:)

#6


2  

I'm using OS X 10.5.8, gcc 4.2.1, python 2.7.5, libjpegv9 and Pillow 2.1.0 (which is based on PIL).

我使用的是OS X 10.5.8,gcc 4.2.1,python 2.7.5,libjpegv9和Pillow 2.1.0(基于PIL)。

My problem apparently (but it's just a guess) was caused by architecture incompatibilities of the libjpeg and python (and Pillow) builds.

显然我的问题(但这只是猜测)是由libjpeg和python(和Pillow)构建的架构不兼容引起的。

Building python and libjpeg from source using only 32bit arch solved it. I installed all the other python libraries, Pillow included, just by using

仅使用32位arch从源代码构建python和libjpeg解决了它。我安装了所有其他python库,包括Pillow,只需使用

pip install xxxxx

and it worked fine.

它工作得很好。

Details

First I tried both a dmg from the python.org site and a universal build installed via macports. I had not specified universal when installing but macports installed both i386 and ppc architectures anyways.

首先,我尝试了python.org网站的dmg和通过macports安装的通用版本。安装时没有指定通用,但macports无论如何都安装了i386和ppc架构。

That caused me problems because libjpeg compiles only to i386 by default.

这引起了我的问题,因为libjpeg默认只编译为i386。

To check the build of the binaries, I did:

为了检查二进制文件的构建,我做了:

file /usr/bin/python

/usr/bin/python: Mach-O universal binary with 2 architectures

/ usr / bin / python:具有2个体系结构的Mach-O通用二进制文件

/usr/bin/python: Mach-O executable i386

/ usr / bin / python:Mach-O可执行文件i386

/usr/bin/python: Mach-O executable ppc

/ usr / bin / python:Mach-O可执行文件ppc

file /usr/local/lib/libjpeg.dylib 

/usr/local/lib/libjpeg.dylib: Mach-O dynamically linked shared library i386

/usr/local/lib/libjpeg.dylib:Mach -O动态链接共享库i386

When building PIL (or Pillow), it seemed to use the same build options as python "-gcc i386 -gcc ppc" (which seems logical).

在构建PIL(或Pillow)时,它似乎使用与python“-gcc i386 -gcc ppc”相同的构建选项(这似乎是合乎逻辑的)。

All went well until it built the "_imaging" module. There, it showed a warning that libjpeg.dylib was not of the right architecture but in the end it showed that JPEG was available just the same.

一切顺利,直到它建立了“_imaging”模块。在那里,它显示了一个警告,libjpeg.dylib不是正确的架构,但最后它显示JPEG可用相同。

#7


1  

There is a packaging fork of PIL that attempts to make it easier to install and support on many modern platforms, including OS X:

PIL的包装分支试图使其更容易在许多现代平台上安装和支持,包括OS X:

You should be able to install it on OS X with pip or easy_install (assuming you have XCode). If you have any trouble, please open a ticket here:

您应该能够使用pip或easy_install在OS X上安装它(假设您有XCode)。如果您有任何问题,请在此打开机票:

#8


0  

Hey check out this article, worked wonders for me on Snow Leopard.

嘿看看这篇文章,在Snow Leopard上为我创造了奇迹。

I'd also recommend using libjpeg 0.6 instead of 0.7 noted in the article.

我还建议使用文章中提到的libjpeg 0.6而不是0.7。

Good luck.

祝你好运。

#9


0  

I have issues installing PIL with brew and easy_install on my Mac too. My solution is to download source code from http://www.pythonware.com/products/pil/, extract the tar ball and use

我在使用brew和easy_install在我的Mac上安装PIL时遇到了问题。我的解决方案是从http://www.pythonware.com/products/pil/下载源代码,解压缩tar球并使用

python setup.py install

to compile and install the package.

编译和安装包。

#1


12  

EDIT: This answer has been getting voted up recently, and I want to modify it to reflect what I'm doing now.

编辑:这个答案最近已被投票,我想修改它以反映我现在正在做的事情。

Firstly, I've switched from MacPorts to Homebrew for package management on Mac OS X. Secondly, I've switched from using my package manager to using pip and virtualenvwrapper to manage my Python libraries.

首先,我已经从MacPorts切换到Homebrew以便在Mac OS X上进行包管理。其次,我已经从使用我的包管理器切换到使用pip和virtualenvwrapper来管理我的Python库。

Why I switched:

为什么我切换:

At first, with just a few Django projects, it was very easy to keep everything up to date using MacPorts. It was also fairly easy to have multiple versions of Python using python_select. What I didn't realize was that I was doing a pretty terrible job of keeping multiple libraries working side-by-side. It became obvious as I upgraded my packages that sometimes I really didn't want a project's Django version to change. After a couple of Django 1.1 projects (now running Django 1.3) started exhibiting weird behaviour (forms failing to submit because of CSRF middleware changes, small differences in Django libraries, admin app assets changing, and so on) it became clear that I should look into a better solution.

首先,只需几个Django项目,就可以很容易地使用MacPorts保持最新状态。使用python_select创建多个版本的Python也相当容易。我没有意识到的是,我正在做一个非常糟糕的工作,让多个库并排工作。很明显,当我升级我的软件包时,有时候我真的不希望项目的Django版本发生变化。在几个Django 1.1项目(现在运行Django 1.3)之后开始表现出奇怪的行为(由于CSRF中间件更改,Django库中的小差异,管理应用程序资产更改等等而无法提交表单),很明显我应该看一下进入更好的解决方案。

What I do now:

我现在应该做什么:

On Mac OS X I'm moved over to using pip and virtualenvwrapper. First off, I install virtualenvwrapper:

在Mac OS X上,我转而使用pip和virtualenvwrapper。首先,我安装virtualenvwrapper:

pip install virtualenvwrapper

This will grab virtualenv and virtualenvwrapper. You then need to add the following to your .bashrc or .profile and source it or open a new shell.

这将抓住virtualenv和virtualenvwrapper。然后,您需要将以下内容添加到.bashrc或.profile并获取它或打开一个新shell。

export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh # where Homebrew places it
export VIRTUALENVWRAPPER_VIRTUALENV_ARGS='--no-site-packages' # optional

Line 1 sets up the variable workon needs to find its files. Line 2 points to the main shell script (the path here is where Homebrew places the file, it might be different if you're using another package manager). Line 3 is optional, but I really like it: it makes sure that no currently installed libraries in the "main" site-packages repository will leak into your newly created virtual environment. I find this keeps things clean and leads to fewer surprises down the road as things are upgraded.

第1行设置变量workon需要查找其文件。第2行指向主shell脚本(此处的路径是Homebrew放置文件的位置,如果您使用另一个包管理器,它可能会有所不同)。第3行是可选的,但我非常喜欢它:它确保“main”site-packages存储库中当前安装的库不会泄漏到新创建的虚拟环境中。我发现这样可以保持物品清洁,并且随着物品升级,可以减少意外情况。

The next step is to create a new virtual environment:

下一步是创建一个新的虚拟环境:

mkvirtualenv testEnvironmentName

After making the environment, you'll be placed into it. If you kept the --no-site-packages flag, you can type pip freeze to see that your Python library slate is now blank. To escape from the virtual environment, use the deactivate command. To get into your virtualenv again, use workon testEnvironmentName. Note that you can use tab completion on the name of the environment. Also note that typing workon by itself will give you a list of available environments. From here you can pip install any libraries you want, including PIL.

在创造环境之后,你将被置于其中。如果保留了--no-site-packages标志,则可以键入pip freeze以查看您的Python库平板现在是空白的。要退出虚拟环境,请使用deactivate命令。要再次进入virtualenv,请使用workon testEnvironmentName。请注意,您可以在环境名称上使用Tab键完成。另请注意,单独输入workon将为您提供可用环境的列表。从这里你可以pip安装你想要的任何库,包括PIL。

To learn more about virtualenvwrapper, I recommend checking out the documentation.

要了解有关virtualenvwrapper的更多信息,我建议您查看文档。

Here's another great resource which taught me a lot about using virtualenvwrapper (or just view the screencast)

这是另一个很好的资源,它教会了我很多关于使用virtualenvwrapper(或只是查看截屏视频)


ORIGINAL:

原版的:

You can also instal PIL using MacPorts. The package name is py-pil. Here's more information on the package. I'm pretty fond of MacPorts over pip, as I find it gives me a bit more configurability when it comes to keeping several versions of python and several libraries installed.

您也可以使用MacPorts安装PIL。包名称是py-pil。以下是有关该软件包的更多信息。我非常喜欢MacPorts over pip,因为我发现它在保持几个版本的python和几个库的安装方面给了我更多的可配置性。

Here are the installation instructions for MacPorts: http://www.macports.org/install.php

以下是MacPorts的安装说明:http://www.macports.org/install.php

See also: What is the most compatible way to install python modules on a Mac?

另请参阅:在Mac上安装python模块最兼容的方法是什么?

#2


14  

Following steps worked for me:

以下步骤对我有用:

$ brew install pip
$ export ARCHFLAGS="-arch i386 -arch x86_64"
$ pip install pil

#3


6  

Yes, I have issues with PIL on 10.6.6 too, homebrew and easy_install.

是的,我在10.6.6上也有PIL问题,自制软件和easy_install。

The easiest solution for me was to easy_install PIL / pip install PIL, navigate to /Library/Python/2.6/site-packages/, and symlink the PIL-1.1.7-.....egg file to PIL

对我来说最简单的解决方案是easy_install PIL / pip install PIL,导航到/Library/Python/2.6/site-packages/,并将PIL-1.1.7 -... egg文件符号链接到PIL

ln -s PIL-................egg PIL


>>> import PIL
>>> from PIL import Image
# no more problems.

Edit: These days, I try to use Pillow, a library built to help install PIL. Try pip install pillow - can't hurt!

编辑:这些天,我尝试使用Pillow,一个帮助安装PIL的库。试试pip安装枕头 - 不能伤害!

#4


5  

It might be easier to pinpoint your issue if you can elaborate on what you tried and what error messages were generated with those attempts. Here's some probable solutions that you may or may not have attempted:

如果您可以详细说明您尝试过的内容以及这些尝试生成的错误消息,则可能更容易查明您的问题。以下是您可能尝试过或未尝试过的一些可能的解决方案:

pip install pil

if you dont have pip, try

如果你没有pip,试试吧

easy_install pil

Since you're on the Mac, you can also get HomeBrew (a package manager) and then try

既然你在Mac上,你也可以获得HomeBrew(包管理器),然后尝试

brew install pil

or Macports has a PIL package here.

或者Macports在这里有一个PIL包。

Or build from source?

或者从源码构建?

More importantly, the PIL README states,

更重要的是,PIL README说明,

*--------------------------------------------------------------------

* ------------------------------------------------- -------------------

Additional notes for Mac OS X

On Mac OS X you will usually install additional software such as libjpeg or freetype with the "fink" tool, and then it ends up in "/sw". If you have installed the libraries elsewhere, you may have to tweak the "setup.py" file before building.*

在Mac OS X上,您通常会使用“fink”工具安装其他软件,如libjpeg或freetype,然后以“/ sw”结尾。如果您已在其他地方安装了库,则可能需要在构建之前调整“setup.py”文件。*

That could be your issue. Good luck!

那可能是你的问题。祝你好运!

#5


2  

After fresh OS installation tried these steps:

在新的操作系统安装后尝试以下步骤

  1. Installed homebrew
  2. 安装自制软件
  3. brew install libjpeg
  4. brew安装libjpeg
  5. brew install pil
  6. 酿造安装
  7. easy_install pil
  8. easy_install pil
  9. cd /Library/Python/2.6/site-packages
  10. cd /Library/Python/2.6/site-packages
  11. ln -s /usr/local/Cellar/pil/1.1.7/lib/python2.6/site-packages/PIL PIL
  12. ln -s /usr/local/Cellar/pil/1.1.7/lib/python2.6/site-packages/PIL PIL

After that I was able to load and save jpeg files... I know that this issue has a lot of different solutions and I'm not 100% my way will work for other, but it's worth to try if you just bumping your head in to the wall :)

之后,我能够加载并保存jpeg文件...我知道这个问题有很多不同的解决方案,我不是100%我的方式会为其他人工作,但是如果你只是碰到头脑,那就值得尝试一下在墙上:)

#6


2  

I'm using OS X 10.5.8, gcc 4.2.1, python 2.7.5, libjpegv9 and Pillow 2.1.0 (which is based on PIL).

我使用的是OS X 10.5.8,gcc 4.2.1,python 2.7.5,libjpegv9和Pillow 2.1.0(基于PIL)。

My problem apparently (but it's just a guess) was caused by architecture incompatibilities of the libjpeg and python (and Pillow) builds.

显然我的问题(但这只是猜测)是由libjpeg和python(和Pillow)构建的架构不兼容引起的。

Building python and libjpeg from source using only 32bit arch solved it. I installed all the other python libraries, Pillow included, just by using

仅使用32位arch从源代码构建python和libjpeg解决了它。我安装了所有其他python库,包括Pillow,只需使用

pip install xxxxx

and it worked fine.

它工作得很好。

Details

First I tried both a dmg from the python.org site and a universal build installed via macports. I had not specified universal when installing but macports installed both i386 and ppc architectures anyways.

首先,我尝试了python.org网站的dmg和通过macports安装的通用版本。安装时没有指定通用,但macports无论如何都安装了i386和ppc架构。

That caused me problems because libjpeg compiles only to i386 by default.

这引起了我的问题,因为libjpeg默认只编译为i386。

To check the build of the binaries, I did:

为了检查二进制文件的构建,我做了:

file /usr/bin/python

/usr/bin/python: Mach-O universal binary with 2 architectures

/ usr / bin / python:具有2个体系结构的Mach-O通用二进制文件

/usr/bin/python: Mach-O executable i386

/ usr / bin / python:Mach-O可执行文件i386

/usr/bin/python: Mach-O executable ppc

/ usr / bin / python:Mach-O可执行文件ppc

file /usr/local/lib/libjpeg.dylib 

/usr/local/lib/libjpeg.dylib: Mach-O dynamically linked shared library i386

/usr/local/lib/libjpeg.dylib:Mach -O动态链接共享库i386

When building PIL (or Pillow), it seemed to use the same build options as python "-gcc i386 -gcc ppc" (which seems logical).

在构建PIL(或Pillow)时,它似乎使用与python“-gcc i386 -gcc ppc”相同的构建选项(这似乎是合乎逻辑的)。

All went well until it built the "_imaging" module. There, it showed a warning that libjpeg.dylib was not of the right architecture but in the end it showed that JPEG was available just the same.

一切顺利,直到它建立了“_imaging”模块。在那里,它显示了一个警告,libjpeg.dylib不是正确的架构,但最后它显示JPEG可用相同。

#7


1  

There is a packaging fork of PIL that attempts to make it easier to install and support on many modern platforms, including OS X:

PIL的包装分支试图使其更容易在许多现代平台上安装和支持,包括OS X:

You should be able to install it on OS X with pip or easy_install (assuming you have XCode). If you have any trouble, please open a ticket here:

您应该能够使用pip或easy_install在OS X上安装它(假设您有XCode)。如果您有任何问题,请在此打开机票:

#8


0  

Hey check out this article, worked wonders for me on Snow Leopard.

嘿看看这篇文章,在Snow Leopard上为我创造了奇迹。

I'd also recommend using libjpeg 0.6 instead of 0.7 noted in the article.

我还建议使用文章中提到的libjpeg 0.6而不是0.7。

Good luck.

祝你好运。

#9


0  

I have issues installing PIL with brew and easy_install on my Mac too. My solution is to download source code from http://www.pythonware.com/products/pil/, extract the tar ball and use

我在使用brew和easy_install在我的Mac上安装PIL时遇到了问题。我的解决方案是从http://www.pythonware.com/products/pil/下载源代码,解压缩tar球并使用

python setup.py install

to compile and install the package.

编译和安装包。