Using Dock Pillows

I cannot install python PIL in docker for some reason. Here is a description of what I have:

requirements.txt

Pillow
flask
redis

Dockerfile

FROM python:2.7
ADD . /code
WORKDIR /code
RUN pip install -r requirements.txt
CMD python app.py

app.py

import PIL

Teams

$ sudo docker build -t web .
Installing collected packages: Pillow, Werkzeug, MarkupSafe, Jinja2, itsdangerous, flask, redis
Successfully installed Jinja2-2.8 MarkupSafe-0.23 Pillow-2.9.0  Werkzeug-0.10.4 flask-0.10.1 itsdangerous-0.24 redis-2.10.3
---> 91dfb38bd480
Removing intermediate container 4e4ca5801814
Step 4 : CMD python app.py
 ---> Running in e71453f2fab6
 ---> d62996658bd6
 Removing intermediate container e71453f2fab6
 Successfully built d62996658bd6

$ sudo docker-compose up

Here is what I get: Exit

web_1   |   File "app.py", line 1, in <module>
web_1   |     import PIL
web_1   | ImportError: No module named PIL

I thought maybe adding PIL to the requirements. txt will work, but here's what happens when I build

$ sudo docker build -t web .
....
Collecting PIL (from -r requirements.txt (line 1))
Could not find a version that satisfies the requirement PIL (from -r    requirements.txt (line 1)) (from versions: )
Some externally hosted files were ignored as access to them may be  unreliable (use --allow-external PIL to allow).
No matching distribution found for PIL (from -r requirements.txt (line 1))

Any idea what to do next?

+7
source share
1 answer

PIL will be the Python Image Library (PIL)
(sometimes you will need to import Imageinsteadimport PIL )

" Python (PIL)? ", .

sudo apt-get build-dep python-imaging
sudo apt-get install libjpeg62 libjpeg62-dev
pip install PIL

a5huynh/scrapyd-playground/Dockerfile Pillow (Python Imaging Library).

( , , , : PIL Pillow.
- , PIL, )

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

:

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

2019 (4 ) . , :

/ , , OSError: decoder tiff_lzw not available

:

, - Pillow (5.0), tiff .

+5

Source: https://habr.com/ru/post/1609145/


All Articles