首页 > 代码库 > Mac下安装PIL库

Mac下安装PIL库

首先,下载jpegsrc、zlib、PIL

python Imaging Library 1.1.7 Source Kit

jpegsrc.v9a.tar.gz 

zlib-1.2.8.tar.gz

然后,解压上述库,顺带说下使用命令解压库

tar -zxvf zlib-1.2.8.tar.gz

 1.安装jpeg

进入jpeg目录下./configuremakesudo make install

 2.安装zlib

进入zlib-1.2.7目录下./configuremakesudo make install

 3.安装PIL

修改root路径

进入Imaging-1.1.7目录下打开setup.py文件加入jpeg、zlip路径找到JPEG_ROOT、ZLIB_ROOT修改如下:JPEG_ROOT = "/usr/local/include" ZLIB_ROOT = "/usr/local/include"

 开始安装

python setup.py build_ext -i

 若出现错误

‘X11/Xlib.h‘ file not found

则运行如下命令

ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers/X11 /usr/local/include/X11

其中红色部分为对应系统版本

 

Mac下安装PIL库