ubuntu下如何正确安装PIL

step one:

$ sudo apt-get install libjpeg-dev

$ sudo apt-get install libfreetype6-dev

step two:

$ sudo ln -s /usr/lib/i386-linux-gnu/libz.so /usr/lib/libz.so

$ sudo ln -s /usr/lib/i386-linux-gnu/libjpeg.so /usr/lib/libjpeg.so

$ sudo ln -s /usr/lib/i386-linux-gnu/libfreetype.so /usr/lib/libfreetype.so

step three:

设置PIL安装文件中的setup.py

JPEG_ROOT = libinclude("/usr/")

ZLIB_ROOT = libinclude("/usr/")

FREETYPE_ROOT = libinclude("/usr/")

编译文件:

$ sudo python setup.py build_ext -i

安装文件:

$ sudo python setup.py install


测试是否安装成功:

>>> from PIL import _imaging as core
>>> core.jpeg_decoder
built -in function jpeg_decoder

其实在编译安装前可通过PIL安装文件下的selftest.py检测当前环境是否满足要求

$ sudo python selftest.py

只要提示libz,libfreetype和libjpeg支持便可,如下:

--- JPEG support available
--- ZLIB (PNG/ZIP) support available
--- FREETYPE2 support available


你可能感兴趣的:(python基础)