pythonubuntu-20.04libtiff

Failed to find TIFF header file (tifflib error on python - Ubuntu 20.04)


I have the following error

ValueError: Failed to find TIFF header file (may be need to run: sudo apt-get install libtiff4-dev)

I already ran:

sudo apt-get install libtiff-dev:i386
sudo apt-get install libtiff-dev

But I still getting the tiff header error. I searched for some solutions but didn't find anything.
Someone have any idea how to solve this?


Solution

  • This problem seems to recur in python virtual environments, and even though I solved it before (mentioned above by @vinicvaz), I ended up here because I forgot how I fixed it.

    The short-term solution is to copy the gist tiff_h_4_1_0.py to wherever the python libtiff got installed (for e.g. venv/lib/python2.7/site-packages/libtiff/tiff_h_4_1_0.py).

    But this won't work when the libtiff library gets updated again past 4.1.0. To fix it with later versions, copy the tiff.h library header from /usr/include/x86_64-linux-gnu/tiff.h to venv/include/ (create the include directory in venv if it doesn't exist). This will cause the new version of the tiff_h_x_y_z.py file to get generated the first time you import libtiff.