I am trying to build a docker image for my django project. The project used pillow and hence I have it in my requiements.txt file. But I am getting an error while building the image
Here is my Dockerfile
# pull the official base image
FROM python:3.9.6-alpine
# set work directory
WORKDIR /usr/src/app
# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
# install dependencies
RUN python3 -m pip install --upgrade pip
COPY ./requirements.txt /usr/src/app
RUN pip install -r requirements.txt
# copy project
COPY . /usr/src/app
EXPOSE 8000
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]
Here’s my requirements.txt file
asgiref==3.4.1
Django==3.2.9
django-cors-headers==3.11.0
djangorestframework==3.13.1
djangorestframework-simplejwt==5.0.0
Pillow==9.0.1
PyJWT==2.3.0
pytz==2021.3
sqlparse==0.4.2
whitenoise==5.3.0
Here’s the error I am getting
Building wheels for collected packages: Pillow
#9 75.27 Building wheel for Pillow (setup.py): started
#9 76.43 Building wheel for Pillow (setup.py): finished with status 'error'
#9 76.49 error: subprocess-exited-with-error
#9 76.49
#9 76.49 × python setup.py bdist_wheel did not run successfully.
#9 76.49 │ exit code: 1
#9 76.49 ╰─> [177 lines of output]
#9 76.49 running bdist_wheel
#9 76.49 running build
#9 76.49 running build_py
#9 76.49 creating build
#9 76.49 creating build/lib.linux-x86_64-3.9
#9 76.49 creating build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/ContainerIO.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/GribStubImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/ImageFilter.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/SpiderImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/EpsImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/PdfImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/ImagePath.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/ImageEnhance.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/GimpGradientFile.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/BufrStubImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/IptcImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/PcdImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/ExifTags.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/ImageDraw2.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/__main__.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/ImageMorph.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/MpoImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/ImageStat.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/FliImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/TiffTags.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/ImagePalette.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/SunImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/PcfFontFile.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/ImageSequence.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/ImageGrab.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/GimpPaletteFile.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/TarIO.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/MpegImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/PalmImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/FontFile.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/ImageChops.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/PixarImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/ImageFont.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/ImageColor.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/_version.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/WebPImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/ImageTransform.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/PpmImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/ImageTk.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/ImageQt.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/FpxImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/PsdImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/GdImageFile.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/_binary.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/ImtImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/TiffImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/PaletteFile.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/XpmImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/PngImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/_util.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/ImageFile.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/BdfFontFile.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/PcxImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/JpegImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/ImageCms.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/GifImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/WalImageFile.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/MicImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/FitsStubImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/ImageMode.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/IcoImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/ImageOps.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/JpegPresets.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/IcnsImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/Image.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/Hdf5StubImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/DdsImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/features.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/MspImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/Jpeg2KImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/PyAccess.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/BmpImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/SgiImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/CurImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/ImageDraw.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/TgaImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/DcxImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/XbmImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/ImImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/ImageShow.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/ImageMath.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/_tkinter_finder.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/WmfImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/BlpImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/PSDraw.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/ImageWin.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/FtexImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/XVThumbImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/PdfParser.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/__init__.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/McIdasImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 copying src/PIL/GbrImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 76.49 running egg_info
#9 76.49 writing src/Pillow.egg-info/PKG-INFO
#9 76.49 writing dependency_links to src/Pillow.egg-info/dependency_links.txt
#9 76.49 writing top-level names to src/Pillow.egg-info/top_level.txt
#9 76.49 reading manifest file 'src/Pillow.egg-info/SOURCES.txt'
#9 76.49 reading manifest template 'MANIFEST.in'
#9 76.49 warning: no files found matching '*.c'
#9 76.49 warning: no files found matching '*.h'
#9 76.49 warning: no files found matching '*.sh'
#9 76.49 warning: no previously-included files found matching '.appveyor.yml'
#9 76.49 warning: no previously-included files found matching '.clang-format'
#9 76.49 warning: no previously-included files found matching '.coveragerc'
#9 76.49 warning: no previously-included files found matching '.editorconfig'
#9 76.49 warning: no previously-included files found matching '.readthedocs.yml'
#9 76.49
#9 76.49 File "/usr/local/lib/python3.9/site-packages/setuptools/command/build_ext.py", line 79, in run
#9 76.49 _build_ext.run(self)
#9 76.49 File "/usr/local/lib/python3.9/distutils/command/build_ext.py", line 340, in run
#9 76.49 self.build_extensions()
#9 76.49 File "/tmp/pip-install-elv3vo8i/pillow_3742a79b841d46b5a99d9899bfdece24/setup.py", line 804, in build_extensions
#9 76.49 raise RequiredDependencyException(f)
#9 76.49 __main__.RequiredDependencyException: zlib
#9 76.49
#9 76.49 During handling of the above exception, another exception occurred:
#9 76.49
#9 76.49 Traceback (most recent call last):
#9 76.49 File "<string>", line 2, in <module>
#9 76.49 File "<pip-setuptools-caller>", line 34, in <module>
#9 76.49 File "/tmp/pip-install-elv3vo8i/pillow_3742a79b841d46b5a99d9899bfdece24/setup.py", line 1009, in <module>
#9 76.49 raise RequiredDependencyException(msg)
#9 76.49 __main__.RequiredDependencyException:
#9 76.49
#9 76.49 The headers or library files could not be found for zlib,
#9 76.49 a required dependency when compiling Pillow from source.
#9 76.49
#9 76.49 Please see the install instructions at:
#9 76.49 https://pillow.readthedocs.io/en/latest/installation.html
#9 76.49
#9 76.49
#9 76.49 [end of output]
#9 76.49
#9 76.49 note: This error originates from a subprocess, and is likely not a problem with pip.
#9 76.49 ERROR: Failed building wheel for Pillow
#9 76.49 Running setup.py clean for Pillow
#9 77.35 Failed to build Pillow
#9 77.51 Installing collected packages: pytz, whitenoise, sqlparse, PyJWT, Pillow, asgiref, Django, djangorestframework, django-cors-headers, djangorestframework-simplejwt
#9 77.96 Running setup.py install for Pillow: started
#9 79.24 Running setup.py install for Pillow: finished with status 'error'
#9 79.26 error: subprocess-exited-with-error
#9 79.26
#9 79.26 × Running setup.py install for Pillow did not run successfully.
#9 79.26 │ exit code: 1
#9 79.26 ╰─> [179 lines of output]
#9 79.26 running install
#9 79.26 running build
#9 79.26 running build_py
#9 79.26 creating build
#9 79.26 creating build/lib.linux-x86_64-3.9
#9 79.26 creating build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/ContainerIO.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/GribStubImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/ImageFilter.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/SpiderImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/EpsImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/PdfImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/ImagePath.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/ImageEnhance.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/GimpGradientFile.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/BufrStubImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/IptcImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/PcdImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/ExifTags.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/ImageDraw2.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/__main__.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/ImageMorph.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/MpoImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/ImageStat.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/FliImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/TiffTags.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/ImagePalette.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/SunImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/PcfFontFile.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/ImageSequence.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/ImageGrab.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/GimpPaletteFile.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/TarIO.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/MpegImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/PalmImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/FontFile.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/ImageChops.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/PixarImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/ImageFont.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/ImageColor.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/_version.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/WebPImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/ImageTransform.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/PpmImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/ImageTk.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/ImageQt.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/FpxImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/PsdImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/GdImageFile.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/_binary.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/ImtImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/TiffImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/PaletteFile.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/XpmImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/PngImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/_util.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/ImageFile.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/BdfFontFile.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/PcxImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/JpegImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/ImageCms.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/GifImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/WalImageFile.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/MicImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/FitsStubImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/ImageMode.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/IcoImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/ImageOps.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/JpegPresets.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/IcnsImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/Image.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/Hdf5StubImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/DdsImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/features.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/MspImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/Jpeg2KImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/PyAccess.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/BmpImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/SgiImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/CurImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/ImageDraw.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/TgaImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/DcxImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/XbmImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/ImImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/ImageShow.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/ImageMath.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/_tkinter_finder.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/WmfImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/BlpImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/PSDraw.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/ImageWin.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/FtexImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/XVThumbImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/PdfParser.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/__init__.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/McIdasImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 copying src/PIL/GbrImagePlugin.py -> build/lib.linux-x86_64-3.9/PIL
#9 79.26 running egg_info
#9 79.26 writing src/Pillow.egg-info/PKG-INFO
#9 79.26 writing dependency_links to src/Pillow.egg-info/dependency_links.txt
#9 79.26 writing top-level names to src/Pillow.egg-info/top_level.txt
#9 79.26 reading manifest file 'src/Pillow.egg-info/SOURCES.txt'
#9 79.26 reading manifest template 'MANIFEST.in'
#9 79.26 warning: no files found matching '*.c'
#9 79.26 warning: no files found matching '*.h'
#9 79.26 warning: no files found matching '*.sh'
#9 79.26 warning: no previously-included files found matching '.appveyor.yml'
#9 79.26 warning: no previously-included files found matching '.clang-format'
#9 79.26 warning: no previously-included files found matching '.coveragerc'
#9 79.26 warning: no previously-included files found matching '.editorconfig'
#9 79.26 warning: no previously-included files found matching '.readthedocs.yml'
#9 79.26 warning: no previously-included files found matching 'codecov.yml'
#9 79.26 warning: no previously-included files matching '.git*' found anywhere in distribution
#9 79.26 warning: no previously-included files matching '*.pyc' found anywhere in distribution
#9 79.26 warning: no previously-included files matching '*.so' found anywhere in distribution
#9 79.26 no previously-included directories found matching '.ci'
#9 79.26 adding license file 'LICENSE'
#9 79.26 writing manifest file 'src/Pillow.egg-info/SOURCES.txt'
#9 79.26 warning: build_py: byte-compiling is disabled, skipping.
#9 79.26
#9 79.26 running build_ext
#9 79.26
#9 79.26
#9 79.26 The headers or library files could not be found for zlib,
#9 79.26 a required dependency when compiling Pillow from source.
#9 79.26
#9 79.26 Please see the install instructions at:
#9 79.26 https://pillow.readthedocs.io/en/latest/installation.html
#9 79.26
#9 79.26 Traceback (most recent call last):
#9 79.26 File "/tmp/pip-install-elv3vo8i/pillow_3742a79b841d46b5a99d9899bfdece24/setup.py", line 989, in <module>
#9 79.26 setup(
#9 79.26 File "/usr/local/lib/python3.9/site-packages/setuptools/__init__.py", line 153, in setup
#9 79.26 return distutils.core.setup(**attrs)
#9 79.26 File "/usr/local/lib/python3.9/distutils/core.py", line 148, in setup
#9 79.26 dist.run_commands()
#9 79.26 File "/usr/local/lib/python3.9/distutils/dist.py", line 966, in run_commands
#9 79.26 self.run_command(cmd)
#9 79.26 File "/usr/local/lib/python3.9/distutils/dist.py", line 985, in run_command
#9 79.26 cmd_obj.run()
#9 79.26 File "/usr/local/lib/python3.9/site-packages/setuptools/command/install.py", line 61, in run
#9 79.26 return orig.install.run(self)
#9 79.26 File "/usr/local/lib/python3.9/distutils/command/install.py", line 546, in run
#9 79.26 self.run_command('build')
#9 79.26 File "/usr/local/lib/python3.9/distutils/cmd.py", line 313, in run_command
#9 79.26 self.distribution.run_command(command)
#9 79.26 File "/usr/local/lib/python3.9/distutils/dist.py", line 985, in run_command
#9 79.26 cmd_obj.run()
#9 79.26 File "/usr/local/lib/python3.9/distutils/command/build.py", line 135, in run
#9 79.26 self.run_command(cmd_name)
#9 79.26 File "/usr/local/lib/python3.9/distutils/cmd.py", line 313, in run_command
#9 79.26 self.distribution.run_command(command)
#9 79.26 File "/usr/local/lib/python3.9/distutils/dist.py", line 985, in run_command
#9 79.26 cmd_obj.run()
#9 79.26 File "/usr/local/lib/python3.9/site-packages/setuptools/command/build_ext.py", line 79, in run
#9 79.26 _build_ext.run(self)
#9 79.26 File "/usr/local/lib/python3.9/distutils/command/build_ext.py", line 340, in run
#9 79.26 self.build_extensions()
#9 79.26 File "/tmp/pip-install-elv3vo8i/pillow_3742a79b841d46b5a99d9899bfdece24/setup.py", line 804, in build_extensions
#9 79.26 raise RequiredDependencyException(f)
#9 79.26 __main__.RequiredDependencyException: zlib
#9 79.26
#9 79.26 During handling of the above exception, another exception occurred:
#9 79.26
#9 79.26 Traceback (most recent call last):
#9 79.26 File "<string>", line 2, in <module>
#9 79.26 File "<pip-setuptools-caller>", line 34, in <module>
#9 79.26 File "/tmp/pip-install-elv3vo8i/pillow_3742a79b841d46b5a99d9899bfdece24/setup.py", line 1009, in <module>
#9 79.26 raise RequiredDependencyException(msg)
#9 79.26 __main__.RequiredDependencyException:
#9 79.26
#9 79.26 The headers or library files could not be found for zlib,
#9 79.26 a required dependency when compiling Pillow from source.
#9 79.26
#9 79.26 Please see the install instructions at:
#9 79.26 https://pillow.readthedocs.io/en/latest/installation.html
#9 79.26
#9 79.26
#9 79.26 [end of output]
#9 79.26
#9 79.26 note: This error originates from a subprocess, and is likely not a problem with pip.
#9 79.26 error: legacy-install-failure
#9 79.26
#9 79.26 × Encountered error while trying to install package.
#9 79.26 ╰─> Pillow
#9 79.26
#9 79.26 note: This is an issue with the package mentioned above, not pip.
#9 79.26 hint: See above for output from the failure.
------
executor failed running [/bin/sh -c pip install -r requirements.txt]: exit code: 1
2
Answers
When you a look little bit closely at the error message, you will find a hint to the solution:
zlib
is a library for zip files. So, try to install that with the distribution’s default package manager and retry:Add an additional
RUN
command to yourDockerfile
somewhere before the line where you installrequirements.txt
(or add it into an existingRUN
command to minimize the number of layers):This should do it. You need to install the build dependencies,
zlib-dev
,jpeg-dev
,gcc
, andmusl-dev