如何在 mac os x 10.7.2 Lion 上安装 PIL [英] How can I install PIL on mac os x 10.7.2 Lion
问题描述
我试过谷歌搜索&查找一些其他人的问题.但是,我仍然找不到在 mac os x 10.7.2 Lion 上安装 PIL(适用于 python 2.6 或 2.7)的清晰/简单的方法.
I've tried googling & looking up some other people's questions. However, I still couldn't find a clear/simple recipe to install PIL (for python 2.6 or 2.7) on mac os x 10.7.2 Lion.
推荐答案
如果你使用 homebrew,您只需 brew install pil
即可安装 PIL.然后,您可能需要将安装目录 ($(brew --prefix)/lib/python2.7/site-packages
) 添加到 PYTHONPATH,或将 PIL 目录本身的位置添加到文件中在任何站点包目录中调用 PIL.pth
文件,内容为:
If you use homebrew, you can install the PIL with just brew install pil
. You may then need to add the install directory ($(brew --prefix)/lib/python2.7/site-packages
) to your PYTHONPATH, or add the location of PIL directory itself in a file called PIL.pth
file in any of your site-packages directories, with the contents:
/usr/local/lib/python2.7/site-packages/PIL
(假设 brew --prefix
是 /usr/local
).
或者,您可以从源代码下载/构建/安装它:
Alternatively, you can just download/build/install it from source:
# download
curl -O -L http://effbot.org/media/downloads/Imaging-1.1.7.tar.gz
# extract
tar -xzf Imaging-1.1.7.tar.gz
cd Imaging-1.1.7
# build and install
python setup.py build
sudo python setup.py install
# or install it for just you without requiring admin permissions:
# python setup.py install --user
我刚刚运行了上面的程序(在 OSX 10.7.2 上,使用 XCode 4.2.1 和系统 Python 2.7.1)并且它构建得很好,尽管我的环境中的某些东西可能是非默认的.
I ran the above just now (on OSX 10.7.2, with XCode 4.2.1 and System Python 2.7.1) and it built just fine, though there is a possibility that something in my environment is non-default.
这篇关于如何在 mac os x 10.7.2 Lion 上安装 PIL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!