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.

- 393
- 1
- 2
- 10
-
1Please add your code and the full error so we can help you. – BrainFl Apr 04 '22 at 13:40
13 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.

- 915
- 5
- 20

- 299
- 2
- 2
-
2Doing this gave yet another error: AttributeError: module 'PIL.TiffTags' has no attribute 'IFD' – qboomerang May 31 '22 at 15:09
-
2
I find that forcing the use of a particular Pillow version may break other packages.
Another solution that works for any Pillow version and avoids deprecation warnings is to insert the code:
import PIL.Image
if not hasattr(PIL.Image, 'Resampling'): # Pillow<9.0
PIL.Image.Resampling = PIL.Image
# Now PIL.Image.Resampling.BICUBIC is always recognized.

- 2,865
- 1
- 27
- 39
The resampling enums were seemingly added in Pillow 9.1.0 (released 3 days ago) via this pull request.
I would imagine your Databricks environment has a different verison.

- 152,115
- 15
- 115
- 172
my way to fix it: pip install --ignore-installed Pillow==9.3.0

- 61
- 1
- 1
-
That is a copy (with different version since it was 8 months ago) of a previous answer. Please, edit to clarify how this answer is different, and better, than previous answer. – chrslg Dec 13 '22 at 22:04
-
This version is what worked for me with fastai, without the `--ignore-installed` though. – arun Aug 01 '23 at 20:28
Same happened when I upgraded some module. I just restarted runtime and it helped.

- 41
- 4
If you don't want to downgrade the Pillow
library, you can try to install the latest matplotlib
:
python3 -m pip install matplotlib==3.7.1

- 91
- 1
- 2
Resampling enum (and other new enums) can be added here. https://github.com/python/typeshed/blob/main/stubs/Pillow/PIL/Image.pyi

- 11
- 1
-
While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/late-answers/33944379) – Niklas Mohrin Mar 07 '23 at 21:33
If you've just installed a Python program with pip
and it raises this error, it's probably because of a conflict with something you've previously installed. In this case pip install Pillow==9.0.0
did not work for me (and it may break something else).
Creating a clean venv for that program should fix it:
$ mkdir frobnicator
$ cd frobnicator
$ python -m venv venv
$ source venv/bin/activate
(venv) $ pip install frobnicator
(venv) $ frobnicator ...

- 24,651
- 6
- 70
- 114
I had the same issue occur in Google Colab.
I first installed Pillow:
!pip install pillow
After that I still got the error, until I restarted the Runtime. Once the runtime was restarted, the error went away.

- 8,872
- 12
- 69
- 83
Well, I had the same issue, so I went with simplest solution by TADA!@! removing it. also it can be fixed with changing it to Image.BICUBIC. results are just the same for me. working code with same valid results.

- 1
- 1
-
1Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Aug 16 '23 at 06:29