4
由于某种原因,我无法在docker中安装python的PIL模块。这里是什么,我有一个说明:在Docker中使用枕头
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
个命令
$ 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
这里就是我得到: 输出
web_1 | File "app.py", line 1, in <module>
web_1 | import PIL
web_1 | ImportError: No module named PIL
我想也许添加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))
任何想法从这里应该做什么?
完美!使用a5huynh/scrapyd-playground/Dockerfile中的配置。但它在一个新的容器上工作,而不是现有的容器。不知道为什么。 – arbazkhan002
一句警告,它混合了两个模块:'PIL'和'Pillow'。枕头是一个维护的叉子和原有的未维护的PIL的替代品,因此您不应该同时安装两者。 – Hugo
@Hugo好点:我已将您的评论添加到答案中,以获得更多的知名度。 – VonC