Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

python - WEBP support not installed error with Pillow included in Anaconda

I have written a small code to open webp image in the Anaconda prompt.

from PIL import Image
im = Image.open('test.webp')

It causes the following error:

C:ProgramDataAnaconda3libsite-packagesPILImage.py:2655: UserWarning: image file could not be identified because WEBP support not installed
  warnings.warn(message)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:ProgramDataAnaconda3libsite-packagesPILImage.py", line 2657, in open
    % (filename if filename else fp))
OSError: cannot identify image file 'test.webp'

The same code works fine in python-3.7.2-amd64 installed in another directory with Pillow 5.4.1.

Package    Version
---------- -------
Pillow     5.4.1
pip        18.1
setuptools 40.6.2

The above code causes the same error in Anaconda prompt, Spyder and Jupyter Notebook. Still the same error even after reinstallation the Anaconda or trying on the different PC.

Anaconda or Miniconda version:

Anaconda 2018.12 for Windows Installer
Python 3.7 version 64-Bit Graphical Installer
Anaconda3-2018.12-Windows-x86_64.exe

Operating System:

Windows 10 Professional 64-Bit

The same issue was reported on GitHub #10737.

conda info

     active environment : base
    active env location : C:ProgramDataAnaconda3
            shell level : 1
       user config file : C:Userschen.condarc
 populated config files : C:Userschen.condarc
          conda version : 4.5.12
    conda-build version : 3.17.6
         python version : 3.7.1.final.0
       base environment : C:ProgramDataAnaconda3  (writable)
           channel URLs : https://repo.anaconda.com/pkgs/main/win-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/free/win-64
                          https://repo.anaconda.com/pkgs/free/noarch
                          https://repo.anaconda.com/pkgs/r/win-64
                          https://repo.anaconda.com/pkgs/r/noarch
                          https://repo.anaconda.com/pkgs/pro/win-64
                          https://repo.anaconda.com/pkgs/pro/noarch
                          https://repo.anaconda.com/pkgs/msys2/win-64
                          https://repo.anaconda.com/pkgs/msys2/noarch
          package cache : C:ProgramDataAnaconda3pkgs
                          C:UserschenAppDataLocalcondacondapkgs
       envs directories : C:ProgramDataAnaconda3envs
                          C:UserschenAppDataLocalcondacondaenvs
                          C:Userschen.condaenvs
               platform : win-64
             user-agent : conda/4.5.12 requests/2.21.0 CPython/3.7.1 Windows/10 Windows/10.0.17763
          administrator : True
             netrc file : None
           offline mode : False

conda list --show-channel-urls

# packages in environment at C:ProgramDataAnaconda3:
#
# Name                    Version                   Build  Channel
_ipyw_jlab_nb_ext_conf    0.1.0                    py37_0    defaults
alabaster                 0.7.12                   py37_0    defaults
anaconda                  2018.12                  py37_0    defaults
anaconda-client           1.7.2                    py37_0    defaults
anaconda-navigator        1.9.6                    py37_0    defaults
anaconda-project          0.8.2                    py37_0    defaults
asn1crypto                0.24.0                   py37_0    defaults
astroid                   2.1.0                    py37_0    defaults
astropy                   3.1              py37he774522_0    defaults
atomicwrites              1.2.1                    py37_0    defaults
attrs                     18.2.0           py37h28b3542_0    defaults
babel                     2.6.0                    py37_0    defaults
backcall                  0.1.0                    py37_0    defaults
backports                 1.0                      py37_1    defaults
backports.os              0.1.1                    py37_0    defaults
backports.shutil_get_terminal_size 1.0.0                    py37_2    defaults
beautifulsoup4            4.6.3                    py37_0    defaults
bitarray                  0.8.3            py37hfa6e2cd_0    defaults
bkcharts                  0.2                      py37_0    defaults
blas                      1.0                         mkl    defaults
blaze                     0.11.3                   py37_0    defaults
bleach                    3.0.2                    py37_0    defaults
blosc                     1.14.4               he51fdeb_0    defaults
bokeh                     1.0.2                    py37_0    defaults
boto                      2.49.0                   py37_0    defaults
bottleneck                1.2.1            py37h452e1ab_1    defaults
bzip2                     1.0.6                hfa6e2cd_5    defaults
ca-certificates           2018.03.07                    0    defaults
certifi                   2018.11.29               py37_0    defaults
cffi                      1.11.5           py37h74b6da3_1    defaults
chardet                   3.0.4                    py37_1    defaults
click                     7.0                      py37_0    defaults
cloudpickle               0.6.1                    py37_0    defaults
clyent                    1.2.2                    py37_1    defaults
colorama                  0.4.1                    py37_0    defaults
comtypes                  1.1.7                    py37_0    defaults
conda                     4.5.12                   py37_0    defaults
conda-build               3.17.6                   py37_0    defaults
conda-env                 2.6.0                         1    defaults
conda-verify              3.1.1                    py37_0    defaults
console_shortcut          0.1.1                         3    defaults
contextlib2               0.5.5                    py37_0    defaults
cryptography              2.4.2            py37h7a1dbc1_0    defaults
curl                      7.63.0            h2a8f88b_1000    defaults
cycler                    0.10.0                   py37_0    defaults
cython                    0.29.2           py37ha925a31_0    defaults
cytoolz                   0.9.0.1          py37hfa6e2cd_1    defaults
dask                      1.0.0                    py37_0    defaults
dask-core                 1.0.0                    py37_0    defaults
datashape                 0.5.4                    py37_1    defaults
decorator                 4.3.0                    py37_0    defaults
defusedxml                0.5.0                    py37_1    defaults
distributed               1.25.1                   py37_0    defaults
docutils                  0.14                     py37_0    defaults
entrypoints               0.2.3                    py37_2    defaults
et_xmlfile                1.0.1                    py37_0    defaults
fastcache                 1.0.2            py37hfa6e2cd_2    defaults
filelock                  3.0.10                   py37_0    defaults
flask                     1.0.2                    py37_1    defaults
flask-cors                3.0.7                    py37_0    defaults
freetype                  2.9.1                ha9979f8_1    defaults
future                    0.17.1                   py37_0    defaults
get_terminal_size         1.0.0                h38e98db_0    defaults
gevent                    1.3.7            py37he774522_1    defaults
glob2                     0.6                      py37_1    defaults
greenlet                  0.4.15           py37hfa6e2cd_0    defaults
h5py                      2.8.0            py37h3bdd7fb_2    defaults
hdf5                      1.10.2               hac2f561_1    defaults
heapdict                  1.0.0                    py37_2    defaults
html5lib                  1.0.1                    py37_0    defaults
icc_rt                    2019.0.0             h0cc432a_1    defaults
icu                       58.2                 ha66f8fd_1    defaults
idna                      2.8                      py37_0    defaults
imageio                   2.4.1                    py37_0    defaults
imagesize                 1.1.0                    py37_0    defaults
importlib_metadata        0.6                      py37_0    defaults
intel-openmp              2019.1                      144    defaults
ipykernel                 5.1.0            py37h39e3cac_0    defaults
ipython                   7.2.0            py37h39e3cac_0    defaults
ipython_genutils          0.2.0                    py37_0    defaults
ipywidgets                7.4.2                    py37_0    defaults
isort                     4.3.4                    py37_0    defaults
itsdangerous              1.1.0                    py37_0    defaults
jdcal                     1.4                      py37_0    defaults
jedi                      0.13.2                   py37_0    defaults
jinja2                    2.10                     py37_0    defaults
jpeg                      9b                   hb83a4c4_2    defaults
jsonschema                2.6.0                    py37_0    defaults
jupyter                   1.0.0                    py37_7    defaults
jupyter_client            5.2.4                    py37_0    defaults
jupyter_console           6.0.0                    py37_0    defaults
jupyter_core              4.4.0                    py37_0    defaults
jupyterlab                0.35.3                   py37_0    defaults
jupyterlab_server         0.2.0                    py37_0    defaults
keyring                   17.0.0                   py37_0    defaults
kiwisolver                1.0.1            py37h6538335_0    defaults
krb5                      1.16.1               hc04afaa_7    defaults
lazy-object-proxy         1.3.1            py37hfa6e2cd_2    defaults
libarchive                3.3.3                h0643e63_5    defaults
libcurl                   7.63.0            h2a8f88b_1000    defaults
libiconv                  1.15                 h1df5818_7    defaults
libpng                    1.6.35               h2a8f88b_0    defaults
libsodium                 1.0.16               h9d3ae62_0    defaults
libssh2                   1.8.0                h7a1dbc1_4    defaults
libtiff                   4.0.9                h36446d0_2    defaults
libxml2                   2.9.8                hadb2253_1    defaults
libxslt                   1.1.32               hf6f1972_0    defaults
llvmlite                  0.26.0           py37ha925a31_0    defaults
locket                    0.2.0                    py37_1    defaults
lxml                      4.2.5            py37hef2cd61_0    defaults
lz4-c                     1.8.1.2              h2fa13f4_0    defaults
lzo                       2.10                 h6df0209_2    defaults
m2w64-gcc-libgfortran     5.3.0                         6    defaults
m2w64-gcc-libs            5.3.0                         7    defaults
m2w64-gcc-libs-core       5.3.0                         7    defaults
m2w64-gmp                 6.1.0                         2    defaults
m2w64-libwinpthread-git   5.0.0.4634.697f757               2    defaults
markupsafe                1.1.0            py37he774522_0    defaults
matplotlib                3.0.2            py37hc8f65d3_0    defaults
mccabe                    0.6.1                    py37_1    defaults
menuinst                  1.4.14           py37hfa6e2cd_0    default

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The pillow docs:

Many of Pillow’s features require external libraries:
[...]
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.


I tried to fix this with the following command. It did not fix the issue for me. But it could be useful for others

conda install libwebp

This installs version 1.0.1.
Which results in no webp support

python
> from PIL import features
> print (features.check_module('webp'))
False

Same thing for conda install -c conda-forge libwebp.


It seems to still be an open issue for anaconda. That means perhaps the answer to your problem is to use pip instead of conda.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...