Fixing Pillow segmentation fault

I am currently working a lot with large GeoTIFFs in Python and use Pillow to read them in, then convert them to NumPy arrays for processing. Every now and then, Pillow throws the following error, that I’ve seen on several computers running OS X now:

python TIFFReadDirectory: Warning, Unknown field with tag 42113 (0xa481) encountered. Segmentation fault: 11

Since it always takes me a while to figure out how to fix this, here’s a short note to self, maybe also useful to someone else out there:

  1. Uninstall Pillow:
  2. $ pip uninstall pillow
  3. Install dependencies for building Pillow from source:
  4. $ brew install libtiff libjpeg webp little-cms2
  5. Download Pillow source from PyPI
  6. Unpack and change into the folder with the source code, then build an install via:
    python setup.py install

This has always fixed the problem for me so far. I don’t know whether building from source rather than simply running

pip install pillow

will also fix this problem on other operating systems, but it’s worth a shot if you hit that error.

Leave a Reply

Your email address will not be published. Required fields are marked *