python安装第三方库pillow_安装python库Pillow(PIL)出现问题及解决方法

安装PIL,问题多多,现将出现问题,原因,以及解决方法总结如下:

PIL的官方版本,但是最后一次维护是2009年,现以宣布停止维护,可以运行在python2.7上。

PillowPIL的fork版本,还在继续维护更新,建议安装Pillow。

在安装Pillow之前,请卸载PIL

sudo pip uninstall PIL

安装Pillow 依赖,下面安装是真对ubuntu14.04版本

libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev python-tk```

下面介绍各包提供功能,以及需要的包版本限制(重要)

ibjpeg provides JPEG functionality.

Pillow has been tested with libjpeg versions 6b, 8, 9, and 9a and libjpeg-turbo version 8.

Starting with Pillow 3.0.0, libjpeg is required by default, but may be disabled with the–disable-jpeg

flag.

zlib provides access to compressed PNGs

Starting with Pillow 3.0.0, zlib is required by default, but may be disabled with the–disable-zlib

flag.

libtiff provides compressed TIFF functionality

Pillow has been tested with libtiff versions 3.x and 4.0

libfreetype provides type related services

littlecms provides color management

Pillow version 2.2.1 and below uses liblcms1, Pillow 2.3.0 and above uses liblcms2. Tested with 1.19 and 2.7.

libwebp provides the WebP format.

Pillow has been tested with version 0.1.3, which does not read transparent WebP files.

Versions 0.3.0 and above support transparency.

tcl/tk provides support for tkinter bitmap and photo images.

openjpeg provides JPEG 2000 functionality.

Pillow has been tested with openjpeg 2.0.0 and 2.1.0.

Pillow does not support the earlier 1.5 series which ships with Ubuntu and Debian.

在我的ubuntu14.04中openjpeg版本过低,所以找到openjpeg的官方网站编译安装最新版的openjpeg

cd DownloadPath tar -xzvf Download file name

cd Download file

sudo cmake .

sudo make

sudo make install

完成依赖安装后,使用命令sudo pip install Pillow安装Pillow

Pillow 安装提示

图片中的内容包括Pillow中的各个功能是否支持,如果这些功能出现unsupport ,那么就参考上面包提供功能,检测系统下依赖包是否满足Pillow的要求。

最后打开python解释器,输入

from PIL import Image如果成功导入,说明 安装成功。

在我的ubuntu 14.04安装成功后,在导入仍然提示:[PIL - libopenjp2.so: cannot open shared object file: No such file or directory]这样的错误,在stackoverflow找到了解决方法:

wheries libopenjp2 找到动态链接库的文件位置

cd \etc ls -l |grep 'ld.so.conf' 找到ld.so.conf文件

编辑该文件,将libopenjp2库的路径,添加到ld.so.conf文件中

sudo ldconfig

下面是python找不到动态链接库的原因:以及设置 LD_LIBRARY_PATH有时不能良好解决问题的原因:

sys.path is only searched for Python modules. For dynamic linked libraries, the paths searched must be in LD_LIBRARY_PATH. Check if your LD_LIBRARY_PATH includes /usr/local/lib, and if it doesn’t, add it and try again.In Linux, the environment variable LD_LIBRARY_PATH is a colon-separated set of directories where libraries should be searched for first, before the standard set of directories; this is useful when debugging a new library or using a nonstandard library for special purposes. The environment variable LD_PRELOAD lists shared libraries with functions that override the standard set, just as /etc/ld.so.preload does. These are implemented by the loader /lib/ld-linux.so. I should note that, while LD_LIBRARY_PATH works on many Unix-like systems, it doesn’t work on all; for example, this functionality is available on HP-UX but as the environment variable SHLIB_PATH, and on AIX this functionality is through the variable LIBPATH (with the same syntax, a colon-separated list).

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值