我试图在Docker的Flask服务器上使用pyzbar 0.1.4
该图片是由我们根据来自 Alpine 的python 2.7创建的。
通过安装ZBar
apk update
apk add zbar
我在运行dockerfile时收到以下错误
File "/usr/lib/python2.7/site-packages/pyzbar/pyzbar.py", line 8, in <module> from .wrapper import ( File "/usr/lib/python2.7/site-packages/pyzbar/wrapper.py", line 166, in <module> c_uint_p, # minor File "/usr/lib/python2.7/site-packages/pyzbar/wrapper.py", line 159, in zbar_function return prototype((fname, load_libzbar())) File "/usr/lib/python2.7/site-packages/pyzbar/wrapper.py", line 135, in load_libzbar raise ImportError('Unable to find zbar shared library')ImportError: Unable to find zbar shared library
我正在尝试使用该库解码QR图像
Docker文件
FROM buffetcontainerimages.azurecr.io/base/buffetcloud-python:0.1
RUN pip install --upgrade pip setuptools wheel
COPY wheeldir /opt/app/wheeldir
COPY *requirements.txt /opt/app/src/
RUN pip install --use-wheel --no-index --find-links=/opt/app/wheeldir \
-r /opt/app/src/requirements.txt
RUN pip install --use-wheel --no-index --find-links=/opt/app/wheeldir \
-r /opt/app/src/test-requirements.txt
COPY . /opt/app/src/
WORKDIR /opt/app/src
RUN python setup.py install
EXPOSE 5000
CMD dronedemo
和requirements.txt
requests>=2.18.4
flask>=0.12.2
mechanize>=0.3.6
regex>=2.4.136
PyPDF2>=1.26.0
bs4>=4.5.3
pyzbar>=0.1.4
openpyxl>=2.5.0
selenium>=3.9.0
matplotlib>=2.1.2
当pip安装zbar
`
点安装zbar
收集zbar
正在下载zbar-0.10.tar.bz2
...
zbarmodule.h:26:18:致命错误:zbar.h:没有此类文件或目录
包括
编译终止。
错误:命令“gcc”失败,退出状态为1
`
最佳答案
一个简单的测试,看起来不错。
FROM python:2.7
RUN apt-get update && \
apt-get install -y build-essential libzbar-dev && \
pip install zbar
我尝试了alpine ..但
zbar
库仅在edge分支中可用-试图使其工作起来比它值得的麻烦更多。PS。当心不在docker存储库中的图像。 -不知道那是你的形象
工作示例:
$ docker build -t yourimagenamehere .
Sending build context to Docker daemon 2.048kB
Step 1/2 : FROM python:2.7
---> 9e92c8430ba0
... trunc...
Successfully built d951cd32ea74
Successfully tagged yourimagenamehere:latest
$ docker run -it --rm yourimagenamehere
Python 2.7.14 (default, Dec 12 2017, 16:55:09)
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import zbar
>>>