Using Pillow in Docker
PIL would be the Python Imaging Library (PIL)
(sometimes, you would need import Image
instead of import PIL
)
According to "How do I install python imaging library (PIL)?", you would need to install others components as well
sudo apt-get build-dep python-imaging
sudo apt-get install libjpeg62 libjpeg62-dev
pip install PIL
See also a5huynh/scrapyd-playground/Dockerfile
for an example using Pillow (Python Imaging Library) dependencies.
(But be aware, as Hugo comments below, that this mixes two modules: PIL and Pillow.
Pillow is a maintained fork and a drop-in replacement of the original, unmaintained PIL, so you shouldn't have both installed at the same time)
RUN apt-get update && apt-get install -y \
python-dev python-pip python-setuptools \
libffi-dev libxml2-dev libxslt1-dev \
libtiff4-dev libjpeg8-dev zlib1g-dev libfreetype6-dev \
liblcms2-dev libwebp-dev tcl8.5-dev tk8.5-dev python-tk
# Add the dependencies to the container and install the python dependencies
ADD requirements.txt /tmp/requirements.txt
RUN pip install -r /tmp/requirements.txt && rm /tmp/requirements.txt
RUN pip install Pillow
with requirements:
Pillow==2.6.1
Scrapy==0.24.4
Twisted==14.0.2
boto==2.36.0
cffi==0.8.6
characteristic==14.2.0
cryptography==0.6.1
cssselect==0.9.1
lxml==3.4.0
pyOpenSSL==0.14
pyasn1==0.1.7
pyasn1-modules==0.0.5
pycparser==2.10
pymongo==2.8
queuelib==1.2.2
scrapy-mongodb==0.8.0
scrapyd==1.0.1
service-identity==14.0.0
six==1.8.0
w3lib==1.10.0
zope.interface==4.1.1
In 2019 (4 years later), Daniel W. complains that:
the decoders / image processors are still missing which results in error like
OSError: decoder tiff_lzw not available
He adds however:
I found out my problem originated from a buggy Pillow version (5.0), it complained about missing
tiff
stuff but in fact it was not missing.
Add RUN apk add zlib-dev jpeg-dev gcc musl-dev
in the Dockerfile and then add Pillow in the requirements.txt