Problem :

fatal error: 'libheif/heif.h' file not found occur while Installing via pip on mac

I was trying to install specific module using pip, In order to integrate & use in my automation script. As I execute cmd from terminal I face off with fatal error.

Anyone face this before and know how to fix, please share your thoughts.

2 Answers 2


This issue is still open : More details are here

Found work around : for Mac M1

python -m pip uninstall cffi pyheif pycparser && LDFLAGS="-L$(brow --prefix libheif)/lib" CFLAGS="-I$(brow --prefix libheif)/include" pip install pyheif --no-cache-dir

I borrow this answer from here


The error message indicates that the required library 'libheif' is not installed on your system. In order to resolve the error, you need to install the library first.

Here are the steps to install the library on macOS:

  1. Install Homebrew if you don't have it installed:

    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

  2. Install the libheif library using Homebrew:

    brew install libheif

  3. After installing the library, try installing the module via pip again.

If the problem still persists, please share the exact error message and the command you executed in the terminal.

  • Yeah, agree & Thanks for your reply Milind. Due to security reasons we are not using "Homebrew", hence got resolved successfully using pip finally Jan 31 at 10:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.