Cannot import name 'PILLOW_VERSION' from 'PIL'

Hello,

I have follwoed the instruction properly and I have installed pillow-simd as mentioned here. I am getting the following error on importing from fastai.vision import *

This is how the error looks like

Suprisingly it is using Pillow in anaconda3/lib/python3.7 not from the local environment which is python3.6 not python 3.7.

Please help.

Thanks in advance

It is a known problem with the latest version of Pillow (7.0?) Is that what you’re using?

@jeremy @stas
Actually to be honest, I am not using Pillow. I am using pillow simd as mentened in fastai website. But I am getting this error. Here is a detailed output of conda list

# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                        main  
asn1crypto                1.3.0                    py36_0  
blas                      1.0                         mkl  
ca-certificates           2020.1.1                      0  
certifi                   2019.11.28               py36_0  
cffi                      1.14.0           py36h2e261b9_0  
chardet                   3.0.4                 py36_1003  
conda                     4.8.2                    py36_0  
conda-package-handling    1.6.0            py36h7b6447c_0  
cryptography              2.8              py36h1ba5d50_0  
idna                      2.8                      py36_0  
intel-openmp              2020.0                      166  
jpeg                      9b                   h024ee3a_2  
ld_impl_linux-64          2.33.1               h53a641e_7  
libedit                   3.1.20181209         hc058e9b_0  
libffi                    3.2.1                hd88cf55_4  
libgcc-ng                 9.1.0                hdf63c60_0  
libgfortran-ng            7.3.0                hdf63c60_0  
libjpeg-turbo             2.0.3                h516909a_1    conda-forge
libstdcxx-ng              9.1.0                hdf63c60_0  
libtiff                   4.1.0                h2733197_0  
mkl                       2020.0                      166  
mkl-service               2.3.0            py36he904b0f_0  
mkl_fft                   1.0.15           py36ha843d7b_0  
mkl_random                1.1.0            py36hd6b4f25_0  
ncurses                   6.2                  he6710b0_0  
numpy                     1.18.1           py36h4f9e942_0  
numpy-base                1.18.1           py36hde5b4d6_1  
openssl                   1.1.1d               h7b6447c_4  
pillow-simd               7.0.0.post3              pypi_0    pypi
pip                       20.0.2                   py36_1  
pycosat                   0.6.3            py36h7b6447c_0  
pycparser                 2.19                     py36_0  
pyopenssl                 19.1.0                   py36_0  
pysocks                   1.7.1                    py36_0  
python                    3.6.10               h0371630_0  
readline                  7.0                  h7b6447c_5  
requests                  2.22.0                   py36_1  
ruamel_yaml               0.15.87          py36h7b6447c_0  
scipy                     1.4.1            py36h0b6359f_0  
setuptools                45.2.0                   py36_0  
six                       1.14.0                   py36_0  
sqlite                    3.31.1               h7b6447c_0  
tk                        8.6.8                hbc83047_0  
tqdm                      4.42.1                     py_0  
urllib3                   1.25.8                   py36_0  
wheel                     0.34.2                   py36_0  
xz                        5.2.4                h14c3975_4  
yaml                      0.1.7                had09818_2  
zlib                      1.2.11               h7b6447c_3  
zstd                      1.3.7                h0b5b093_0

You can see I am using pillow-simd 7.0.0.post3.

I am using exactly what is mentioned in the website. Do I need to do something different? As I mentioned already, it is not using pillow-simd from the python36 environment but using PIL from other python37 environment.

Try using something like pip install -U pillow_simd==6.2.2.post1. That fixed it for me.

pillow-simd is the same as pillow with a few optimizations. pillow-7 now uses PIL.Image.__version__ instead of PIL.Image.PILLOW_VERSION. (docs should be updated shortly)

If you get your repos crossed, perhaps start with a fresh conda repository? It’s possible that over time you got some mixups. I trust that if you start afresh everything will work.

But your error has nothing to do with fastai, as you can see the problem is in torchvision, you need to update it, as you can see it has been fixed a few months ago:



You need to install torchvision 0.5.0 or higher which you can do by just updating conda or pip
e.g.: pip install torchvision

a “hack” I learned from here: include these two lines before you import torchvision or fastai

import PIL
PIL.PILLOW_VERSION = PIL.__version__
3 Likes

I edit and change PILLOW_VERSION to version in L5 of funtional.py. It seems working too.