# How to fix ImportError: cannot import name 'PILLOW_VERSION' from 'PIL'

`PILLOW_VERSION` was removed from Pillow. In your own code replace `from PIL import PILLOW_VERSION` with `from PIL import __version__`. If the traceback is inside a library (old torchvision, invertransforms, etc.), upgrade that library; downgrading Pillow is only a stopgap.

## The exact error

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

## Fix it

1. Your code: `from PIL import PILLOW_VERSION` -> `from PIL import __version__`.
   Expected: import works on Pillow 10+

2. A library: `pip install -U [library]`.
   Expected: upstream fixed the import

3. Stopgap only: `pip install "pillow<7"`.
   Expected: old Pillow has the constant (not recommended)

## When this applies

Pillow 7+ and something imports PILLOW_VERSION

## When this does NOT apply

`No module named 'PIL'` (Pillow is not installed at all)

## Versions

Pillow >= 7 (removed), >= 10 (fully gone)

## Why it happens

Pillow deprecated the constant in 5.2, removed it in 7.0.

## Edge cases

torchvision below 0.5 is the most common carrier of this; upgrade torchvision with torch.
