因为在采集中有图像解析的需求,如今将爬虫架构部署在docker中,需要配置一个PIL中image包的情况,因错误较多。故记录下来。
主要参考链接是:
http://www.linuxdiyf.com/linux/18829.html
http://www.linuxdiyf.com/linux/18576.html
PIL安装 1.安装依赖包 1.1 ubuntu安装
apt-get install python-dev
apt-get install libjpeg-dev
apt-get install libjpeg8-dev
apt-get install libpng3
apt-get install libfreetype6-dev
ln -s /usr/lib/`uname -i`-linux-gnu/libfreetype.so /usr/lib
ln -s /usr/lib/`uname -i`-linux-gnu/libjpeg.so /usr/lib
ln -s /usr/lib/`uname -i`-linux-gnu/libz.so /usr/lib
或者
sudo apt-get build-dep python-imaging
由于ubuntu14中libfreetype 的头文件在/usr/include/freetype2目录下,但PIL中使用的路径是freetype,所以需要做以下操作
cd /usr/include
ln -s freetype2 freetype
安装PIL库
$:wget wget http://effbot.org/downloads/Imaging-1.1.7.tar.gz
$:tar -zxvf Imaging-1.1.7
$:cd Imageing-1.1.7
修改setup.py
JPEG_ROOT = "/usr/local/lib"
ZLIB_ROOT = "/usr/local/lib"
FREETYPE_ROOT = "/usr/local/lib"
检查系统环境是否配置成功: $:cd Imaging-1.1.7 $:python setup.py build_ext -i
running build_ext ———————————————– PIL 1.1.7 SETUP SUMMARY ———————————————– version 1.1.7 platform linux2 2.7.6 (default, Jun 22 2015, 17:58:13) [GCC 4.8.2] ———————————————– *** TKINTER support not available (Tcl/Tk 8.6 libraries needed) — JPEG support available — ZLIB (PNG/ZIP) support available — FREETYPE2 support available *** LITTLECMS support not available ———————————————– To add a missing option, make sure you have the required library, and set the corresponding ROOT variable in the setup.py script.
To check the build, run the selftest.py script. 只要JPEG、ZLIB、FREETYPE2 是 available就行 开始PIL的安装:
python setup.py build
(我出现的错误 <freetype/freetype> 不存在,处理方法:cd /usr/include sudo ln -s freetype2 freetype)
python setup.py install
原创文章,转载请注明: 转载自URl-team