由于某些原因,我无法在docker中安装python的PIL模块。下面是我所拥有的一个描述:
requirements.txt
Pillow
flask
redisDockerfile
FROM python:2.7
ADD . /code
WORKDIR /code
RUN pip install -r requirements.txt
CMD python app.pyapp.py
import PIL命令
$ 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下面是我得到的:Output
web_1 | File "app.py", line 1, in <module>
web_1 | import PIL
web_1 | ImportError: No module named PIL我想也许在中添加requirements.txt是可行的,但是当我构建
$ 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))你知道接下来该怎么做吗?
发布于 2015-09-27 06:56:58
PIL将是Python成像库(PIL)
(有时,import PIL)
根据"如何安装python映像库(PIL)?",您还需要安装其他组件
sudo apt-get build-dep python-imaging
sudo apt-get install libjpeg62 libjpeg62-dev
pip install PIL有关使用枕头(Python )依赖项的示例,请参见a5huynh/scrapyd-playground/Dockerfile。
(但是,正如雨果 以下评论一样,请注意,这混合了两个模块: 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年后),丹尼尔W.抱怨说:
解码器/图像处理器仍然缺失,导致类似于
OSError: decoder tiff_lzw not available的错误。
然而,他补充说:
我发现我的问题源于一个婴儿车枕头版(5.0),它抱怨丢失了
tiff的东西,但实际上它并没有丢失。
发布于 2020-09-03 11:46:18
在Dockerfile中添加RUN apk add zlib-dev jpeg-dev gcc musl-dev,然后在requirements.txt中添加枕头
发布于 2020-10-25 10:15:53
文档说:“枕头和皮尔不能在同一个环境中共存。在安装枕头之前,请卸载皮尔。”一旦解决了这个问题,以上Nooras Fatima Ansari的回答就为我解决了这个问题。根据您使用的坞映像,您可以检查枕头码头图像以确定您的停靠映像的确切依赖项。
https://stackoverflow.com/questions/32802682
复制相似问题