Translate

Sunday, January 19, 2020

ImportError: cannot import name 'PILLOW_VERSION' from 'PIL'

ImportError: cannot import name 'PILLOW_VERSION' from 'PIL'
This happens because PILLOW_VERSION is removed in never versions of torchvision,so we need to update torchvision or simply we can change the import PILLOW_VERSION as in never version.
Modify from PIL import Image, ImageOps, ImageEnhance, PILLOW_VERSION to from PIL import Image, ImageOps, ImageEnhance, __version__ in functional.py approx line number 
Modify PILLOW_VERSION = __version__ = _version.__version__ to __version__ = __version__ = _version.__version__ in __init__.py, approx line no 22.
File path:
  • functional.py/usr/local/lib/python3.5/dist-packages/torchvision/transforms
  • __init__.py/usr/local/lib/python3.5/dist-packages/PIL