Lion 下安装 PIL 1.1.7
首先, 去PIL的官网下载1.1.7版本的source, 地址: http://effbot.org/downloads/Imaging-1.1.7.tar.gz
然后, 安装homebrew, 如果你已经安装了, 则跳过此步, 安装命令为: /usr/bin/ruby -e "$(curl -fsSL https://raw.github.com/gist/323731)"
接着, 我们使用安装lzlib和jpeg的包, 安装命令为: brew install lzlib libjpg
接下来, 我们要去下载freetype2的source, 因为Lion自带的freetype并不能让PIL用, 下载地址为: http://sourceforge.net/projects/freetype/files/. 下载完后, 解压, ./configure && make && make install
最后, 我们解开PIL的压缩包, 进去, 运行python setup.py build_ext -i来编译所有source, 完成后, 运行python selftest.py来检查是不是都编译好了, 出现下面的输出, 证明编译好了
MacBookPro:Imaging-1.1.7 davidx$ python selftest.py -------------------------------------------------------------------- PIL 1.1.7 TEST SUMMARY -------------------------------------------------------------------- Python modules loaded from ./PIL Binary modules loaded from ./PIL -------------------------------------------------------------------- --- PIL CORE support ok --- TKINTER support ok --- JPEG support ok --- ZLIB (PNG/ZIP) support ok --- FREETYPE2 support ok *** LITTLECMS support not installed -------------------------------------------------------------------- Running selftest: --- 57 tests passed.
如果编译好了, 使用sudo python setup.py install即可.
如果你遇到类似这样的错误, 证明你的freetype没有装好:
File "/Library/Python/2.7/site-packages/PIL/ImageFont.py", line 134, in __init__ self.font = core.getfont(file, size, index, encoding) File "/Library/Python/2.7/site-packages/PIL/ImageFont.py", line 34, in __getattr__ raise ImportError("The _imagingft C module is not installed") ImportError: The _imagingft C module is not installed
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。