python – WebP support not enabled in Pillow 2.9.0 on CentOS 7 despite installing libwebp

I’m trying to enable WebP support in Pillow 2.9.0 on CentOS 7. I can only use yum to install packages (I cannot use pip). Here’s what I’ve done so far:

Installed libwebp and libwebp-devel using yum:

yum install libwebp libwebp-devel

The installed version of libwebp is 0.3.0:

# rpm -q libwebp
libwebp-0.3.0-11.el7.x86_64

Reinstalled python-pillow to ensure it is compiled with WebP support:

yum reinstall python-pillow

Checked for WebP support:

python -c "from PIL import Image; print('WebP support:', 'WEBP' in Image.SAVE)"
('WebP support:', False)

Extra info:
I cannot use pip since it’s a legacy system. I am restricted to using yum for package management.
The libwebp and libwebp-devel packages are installed and up to date.
I am using the default CentOS 7 repositories.

Despite these steps, WebP support is still not enabled. What am I missing? Is there something else I need to do to ensure Pillow is compiled with WebP support? I tried to recompile PIL from source code to enable webp support but something went wrong and even simple imports like “from PIL import Image” raised some weird errors like this:

from PIL import Image
Traceback (most recent call last):
  File "", line 1, in 
  File "PIL/Image.py", line 63, in 
    from PIL import _imaging as core
ImportError: cannot import name _imaging

Is there a way to enable webp support with python-pillow 2.9 and python2.7? Maybe I’m doing something wrong?

Read more here: Source link