如何在Mac OS X 10.7.2 Lion上安装PIL [英] How can I install PIL on mac os x 10.7.2 Lion
问题描述
我尝试了Google&查找其他人的问题.但是,我仍然找不到在Mac OS X 10.7.2 Lion上安装PIL(适用于python 2.6或2.7)的清晰/简单配方.
如果使用 homebrew ,您只需使用brew install pil
即可安装PIL.然后,您可能需要将安装目录($(brew --prefix)/lib/python2.7/site-packages
)添加到您的PYTHONPATH中,或将PIL目录本身的位置添加到任何site-packages目录中名为PIL.pth
文件的文件中,内容如下:
/usr/local/lib/python2.7/site-packages/PIL
(假设brew --prefix
是/usr/local
).
或者,您也可以从源代码下载/构建/安装它:
# 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和System Python 2.7.1上)运行了上面的代码,尽管它在我的环境中有可能是非默认的,但它的构建还不错. /p>
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.
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
(assuming brew --prefix
is /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
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屋!