我试图在基于 阿尔卑斯山的 Docker 容器中运行 Python 的 Scrapy。它以前是工作,但现在我想使用 Scrapy 的 图像管道,这需要我安装枕头。
作为一个简化的例子,我尝试了以下 Dockerfile
:
FROM python:alpine
RUN apk --update add libxml2-dev libxslt-dev libffi-dev gcc musl-dev libgcc openssl-dev curl
RUN apk add libjpeg zlib tiff freetype lcms libwebp tcl openjpeg
RUN pip install Pillow
但是,当我尝试构建它时,我得到一个错误,其中包含以下内容:
Traceback (most recent call last):
File "/tmp/pip-build-ft5yzzuv/Pillow/setup.py", line 744, in <module>
zip_safe=not debug_build(), )
File "/usr/local/lib/python3.6/distutils/core.py", line 148, in setup
dist.run_commands()
File "/usr/local/lib/python3.6/distutils/dist.py", line 955, in run_commands
self.run_command(cmd)
File "/usr/local/lib/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/usr/local/lib/python3.6/site-packages/setuptools/command/install.py", line 61, in run
return orig.install.run(self)
File "/usr/local/lib/python3.6/distutils/command/install.py", line 545, in run
self.run_command('build')
File "/usr/local/lib/python3.6/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/local/lib/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/usr/local/lib/python3.6/distutils/command/build.py", line 135, in run
self.run_command(cmd_name)
File "/usr/local/lib/python3.6/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/usr/local/lib/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/usr/local/lib/python3.6/distutils/command/build_ext.py", line 339, in run
self.build_extensions()
File "/tmp/pip-build-ft5yzzuv/Pillow/setup.py", line 545, in build_extensions
raise RequiredDependencyException(f)
__main__.RequiredDependencyException: jpeg
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-ft5yzzuv/Pillow/setup.py", line 756, in <module>
raise RequiredDependencyException(msg)
__main__.RequiredDependencyException:
The headers or library files could not be found for jpeg,
a required dependency when compiling Pillow from source.
Please see the install instructions at:
https://pillow.readthedocs.io/en/latest/installation.html
我通过对 https://pillow.readthedocs.io/en/latest/installation.html的要求,并试图找到相应的包阿尔卑斯山,虽然我找不到一个是 Libimagequant,所以这可能是“罪魁祸首”。尽管如此,它的回溯和错误消息似乎是说 jpeg
丢失了,而我已经安装了 openjpeg
。
如何修改 Dockerfile
使 pip install Pillow
运行?