'Dockerfile on Raspberry Pi 3B+
I'm trying to create a docker image on Raspberry Pi 3B+, which i couldn't managed for days. Before creating Docker image, i implemented the code with virtualenv beforehand, which is working fine and requirements.txt is simplified as possible.
Dockerfile ->
FROM alpine:3.14
WORKDIR /code
RUN apk update
RUN apk add python3
RUN apk add py3-pip
RUN pip install wheel
RUN python3 -m pip install --upgrade pip
RUN python3 -m pip install --upgrade Pillow
# copy the requirements inside docker image
COPY ./requirements.txt /code/requirements.txt
# install dependencies inside docker image
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
# copy the necessary files in the working directory inside docker image
COPY ./ /code
# RUN the code
CMD ["python3", "camera.py"]
requirements.txt ->
numpy==1.22.3
picamera==1.13
Pillow==9.1.0
requests==2.27.1
When i try to build the image by running
sudo docker build -t camera .
I get the following long error
Building wheels for collected packages: Pillow Building wheel for Pillow (setup.py): started Building wheel for Pillow (setup.py): finished with status 'error' error: subprocess-exited-with-error × python setup.py bdist_wheel did not run successfully. │ exit code: 1 ╰─> [177 lines of output] During handling of the above exception, another exception occurred: Traceback (most recent call last): File "<string>", line 2, in <module> File "<pip-setuptools-caller>", line 34, in <module> File "/tmp/pip-install- 7613obru/pillow_a212af14addc481892cfcd3648121cf3/setup.py", line 1009, in <module> raise RequiredDependencyException(msg) __main__.RequiredDependencyException: The headers or library files could not be found for zlib, a required dependency when compiling Pillow from source. Please see the install instructions at: https://pillow.readthedocs.io/en/latest/installation.html [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for Pillow Running setup.py clean for Pillow Failed to build Pillow Installing collected packages: Pillow Running setup.py install for Pillow: started Running setup.py install for Pillow: finished with status 'error' error: subprocess-exited-with-error × Running setup.py install for Pillow did not run successfully. │ exit code: 1 ╰─> [179 lines of output] running install running build running build_py creating build creating build/lib.linux-armv7l-3.9 creating build/lib.linux-armv7l-3.9/PIL copying src/PIL/ImageTk.py -> build/lib.linux-armv7l-3.9/PIL copying src/PIL/ImageDraw2.py -> build/lib.linux-armv7l-3.9/PIL The headers or library files could not be found for zlib, a required dependency when compiling Pillow from source. Please see the install instructions at: https://pillow.readthedocs.io/en/latest/installation.html line 804, in build_extensions raise RequiredDependencyException(f) __main__.RequiredDependencyException: zlib During handling of the above exception, another exception occurred: Traceback (most recent call last): File "<string>", line 2, in <module> File "<pip-setuptools-caller>", line 34, in <module> File "/tmp/pip-install- 7613obru/pillow_a212af14addc481892cfcd3648121cf3/setup.py", line 1009, in <module> raise RequiredDependencyException(msg) __main__.RequiredDependencyException: The headers or library files could not be found for zlib, a required dependency when compiling Pillow from source. Please see the install instructions at: https://pillow.readthedocs.io/en/latest/installation.html [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. error: legacy-install-failure × Encountered error while trying to install package. ╰─> Pillow note: This is an issue with the package mentioned above, not pip. hint: See above for output from the failure.
I've deleted some repetitive lines of error since it was extremely long
Solution 1:[1]
It seems i have development libraries missing, i added the following lines and the error was solved
RUN apk add build-base python3-dev py-pip jpeg-dev zlib-dev py3-wheel py3-setuptools
ENV LIBRARY_PATH=/lib:/usr/lib
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Utku |
