Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Module PIL has not attribute "Resampling"

I have run the same code(with packages I needed) before and it worked, not sure what's happening now. This show the error, AttributeError: module 'PIL.Image' has no attribute 'Resampling'. Probably it's small issue, but I can't figure it out, I am working in databricks.

like image 573
ash1 Avatar asked Sep 05 '25 10:09

ash1


2 Answers

I had the same problem. The easy way is use the old version of Pillow.

pip install Pillow==9.0.0

And your code should work.

Note: You can also use

pip install --ignore-installed Pillow==9.0.0

If for some reason, pip is refusing to install it. Note, however, that it can break dependencies, so use it only as a last resort.

like image 193
YuwinZHANG Avatar answered Sep 08 '25 10:09

YuwinZHANG


I had the same problem and found that I need to replace PIL.Image.Resampling.BICUBIC with PIL.Image.BICUBIC. I am using pillow version 7.1.2

from PIL import Image

im = Image.open('image.png')
im2 = im.resize((512,512),resample=Image.BICUBIC)
display(im2)
like image 27
aposch72 Avatar answered Sep 08 '25 12:09

aposch72