If the pillow package is installed but python says PIL cannot be imported, try uninstalling pillow and installing Pillow. The casing is important. The lowercase one installs the package in site-packages/pil/ while the uppercase one installs it (correctly) in site-packages/PIL/. Alternatively, use import pil for the lowercase version.

Also in certain versions, from PIL import Image results in some other error. In this case, just install a different version. For me, upgrading to the latest version worked.