前言
用python写的图像处理的程序,在开发环境(vscode)中运行的好好的,放到服务器上,就报错:PIL.UnidentifiedImageError: cannot identify image file 'data/heads/girl4.webp'
原因
我用到了python中的Pillow库,这个库正常是支持webp格式的图片处理的,但是在linux下比较特殊,还需要系统安装libwebp
排查
- 首先排除了图片原因
-
from PIL import features print(features.pilinfo())
看到输出显示:
*** WEBP support not installed
*** WEBP Transparency support not installed
*** WEBPMUX support not installed
*** WEBP Animation support not installed
安装libwebp
由于我是redhat6.9,版本非常老,只能手动安装。
wget https://github.com/webmproject/libwebp/archive/v1.2.4.tar.gz
tar -xvf v1.2.4.tar.gz
cd libwebp-1.2.4
./configure --prefix=/usr/local/libwebp
make
sudo make install
安装失败
用的python3.6版本,导致无法正常使用Pillow库,一直卡在找不到libwebp库上。
升级python3.10
先手撸一个3.10先
搞失败了
redhat6.9没法装python310,gcc版本是4.4太低了,总是编译失败。
算了。

