I’m currently getting this error No module named 'PIL.image' when trying to import from fastai.vision.all import *. For context, this is in a Google Colab environment and the only code I’ve run before this line is the standard !pip install -Uqq fastai.
I’m not sure if this is maybe a default version change by Colab for PIL, as the notebook was working fine a few months ago when I last ran it. Does anyone have any idea as to what might be causing this?
I am getting the same error in colab. One thing I noticed is that the colab Python version is 3.7.13 and their fastai version is 2.7.2 When I try it locally, it is a few minor versions of the library back (fastai 2.6.3) It still seems to work in my local install. My python version is 3.7.11
Okay @mike.moloch@muellerzr I’ve figured out what the problem is. The Pillow package removed the Resampling enum (as well as other enums) at some point, I’m guessing possibly around 7.1.2. These enums were reintroduced in an MR for 9.1.0 (you can view the pull request here).
So the solution in Colab is to preface the fastai vision import with:
!pip install Pillow=9.1.0
This will require a runtime restart, which is quite annoying, but if you run PIL.__version__ and it’s on 9.1.0 the imports should work. Maybe just confirm on your side that I’m correct, then I can mark this as the solution. Thanks to you both!