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

Question:

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?

Asked By: vinicvaz

||

Answers:

After a long time searching for a answer I found this discussion on github

igg answer helped me

Same here on ubuntu 20.04, fresh upgrade from 18.04. apt installed libtiff-dev, in python venv, pip install libtiff. Import libtiff in python results in tiff.h not found. copy from /usr/include/x86_64-linux-gnu/tiff.h to venv/include/ fixes it.

Answered By: vinicvaz

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.

Answered By: iggie

Just in case, I have been struggling with that. The solution is to install pylibtiff and NOT libtiff. The latter wrap libtiff and handle the hassle.

Do:
pip install pylibtiff

Answered By: zakrapovic
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.