Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not import PILLOW_VERSION from PIL

Tags:

While importing, Python (Anaconda) gives the following error:

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

I tried removing pillow and then conda install but the error persists.

like image 922
kramer Avatar asked Jan 09 '20 07:01

kramer


1 Answers

Pillow 7.0.0 removed PILLOW_VERSION, you should use __version__ in your own code instead.

  • https://pillow.readthedocs.io/en/stable/deprecations.html#pillow-version-constant

Edit (2020-01-16):

If using torchvision, this has been fixed in v0.5.0. To fix:

  1. Require torchvision>=0.5.0
  2. If Pillow was temporarily pinned, remove the pin

Old info (2020-01-09):

If using torchvision, there is a release planned this week (week 2, 2020) to fix it:

  • https://github.com/pytorch/vision/issues/1712#issuecomment-570286349

The options are:

  • wait for the new torchvision release
  • use the master version of torchvision (eg. pip install -U git+https://github.com/pytorch/vision)
  • install torchvision from a nightly, which also requires a pytorch from a nightly version
  • or install Pillow<7 (eg. pip install "pillow<7")
like image 106
Hugo Avatar answered Oct 05 '22 01:10

Hugo