When trying to import PIL (using Pillow), I get the following error:
from PIL import ImageTk, Image
File \"/usr/local/lib/python2.7/site-packages/PIL/I
That sounds like the wheel uploaded to PyPI was not built for your platform correctly. Unfortunately having the wheel for a PyPI package for your platform is not a guarantee that the wheel will install or work correctly, you're at the mercy of the PyPI package maintainer in this regard.
You should run pip uninstall Pillow
, download the source directly from PyPI, build it manually and run pip install -e <path to rebuilt package>
to install the wheel you built specifically for your machine.
This is a bug in the latest Pillow 5.1.0 release.
It was caused by upgrading Xcode from version 8 to 9.2 for building the binary wheels.
El Capitan 10.11 is the "min macOS to run" for Xcode 8.
Sierra 10.12.6 is the min for Xcode 9.2.
https://en.wikipedia.org/wiki/Xcode#Xcode_7.0_-9.x(since_Free_On-Device_Development
There will be a Pillow 5.1.1 out to fix it at some point.
In the meantime, the workaround is: pip install 'pillow!=5.1.0'
(Or upgrade your macOS, or build from source.)
For more info, see https://github.com/python-pillow/Pillow/issues/3068