Here's the post in English for Stack Overflow:
**Error building pyheif package in Docker on Mac OS (works on Windows)
I'm developing a Python application using Docker with Python 3.12. The application works fine on Windows, but when trying to build it on Mac OS, I encounter an error when installing the pyheif
package. The error is related to a missing header file libheif/heif.h
:
error: command 'gcc' failed with exit status 1
build/temp.linux-aarch64-3.7/_libheif_cffi.c:570:15: fatal error: libheif/heif.h: No such file or directory
Here’s my Dockerfile
:
FROM python:3.12
ENV MODE=testing
EXPOSE 8000
WORKDIR /app
COPY requirements/ ./requirements/
RUN apt-get update && \
apt-get install -y gettext libheif-dev && \
pip3 install --upgrade pip
RUN pip3 install -r requirements/development.txt
RUN mkdir media && mkdir basemod && mkdir main && mkdir templates && mkdir static && mkdir config && mkdir locale && mkdir logs
COPY manage.py ./
COPY secrets.json ./
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]
I've already tried the following:
libheif-dev
package is installed in the Docker image.libheif
is available via Homebrew on Mac by running brew install libheif
.xcode-select --install
.This works perfectly on Windows but fails on Mac OS. How can I resolve the issue with the missing libheif/heif.h
on Mac in Docker? Any suggestions would be appreciated!
Make sure to adapt this post to include any further specific details about your setup if needed!
as damp1113 said install libheif
first.
For macOS:
Install dependencies with Homebrew
brew install cmake make pkg-config x265 libde265 libjpeg libtool
Configure and build project (--preset argument needs CMake >= 3.21):
cd build
cmake --preset=release ..
./configure
make
https://github.com/strukturag/libheif?tab=readme-ov-file#macos
For mac in Docker: https://github.com/carsales/pyheif/issues/47#issuecomment-899575287