Docker build unable to install Pillow
aplaza1 opened this issue · 0 comments
aplaza1 commented
When I try to build the Docker image from master, I get the following error:
#8 10.22 During handling of the above exception, another exception occurred:
#8 10.22
#8 10.22 Traceback (most recent call last):
#8 10.22 File "<string>", line 2, in <module>
#8 10.22 File "<pip-setuptools-caller>", line 34, in <module>
#8 10.22 File "/tmp/pip-install-tp1yvrta/pillow_4da7165a9c46483fbcc00d57ea01d38a/setup.py", line 1035, in <module>
#8 10.22 raise RequiredDependencyException(msg)
#8 10.22 __main__.RequiredDependencyException:
#8 10.22
#8 10.22 The headers or library files could not be found for zlib,
#8 10.22 a required dependency when compiling Pillow from source.
#8 10.22
#8 10.22 Please see the install instructions at:
#8 10.22 https://pillow.readthedocs.io/en/latest/installation.html
#8 10.22
#8 10.22
#8 10.22 [end of output]
#8 10.22
#8 10.22 note: This error originates from a subprocess, and is likely not a problem with pip.
#8 10.22 error: legacy-install-failure
#8 10.22
#8 10.22 × Encountered error while trying to install package.
#8 10.22 ╰─> Pillow
I was only able to build it successfully after adding these build dependencies to the Dockerfile:
RUN apk add -u zlib-dev jpeg-dev gcc musl-dev
I found this solution on this Stack Overflow answer: https://stackoverflow.com/a/71157261