"The headers or library files could not be found for jpeg" installing Pillow on Alpine Linux "The headers or library files could not be found for jpeg" installing Pillow on Alpine Linux python python

"The headers or library files could not be found for jpeg" installing Pillow on Alpine Linux


This worked for me

sudo apt-get install libjpeg-dev zlib1g-devpip install Pillow


In a comment that appears to have been deleted later, someone pointed me to https://github.com/python-pillow/Pillow/blob/c05099f45c0d94a2a98c3609a96bdb6cf7446627/depends/alpine_Dockerfile. Based on that Dockerfile I modified my own as follows:

FROM python:alpineRUN apk --update add libxml2-dev libxslt-dev libffi-dev gcc musl-dev libgcc openssl-dev curlRUN apk add jpeg-dev zlib-dev freetype-dev lcms2-dev openjpeg-dev tiff-dev tk-dev tcl-devRUN pip install Pillow

Now it builds successfully.


I ran into this problem with docker image python:3.6-alpine I solved it by adding these packages apk add jpeg-dev zlib-dev.