在Docker Imag中安装python3.5的zbarlight python包

2024-09-28 21:03:33 发布

您现在位置:Python中文网/ 问答频道 /正文

我想在Docker映像中安装python3.5的zbarlightpython包。在

Dockerfile如下所示

FROM python:3.5
WORKDIR /app
ADD . /app
RUN pip3 install -r requirements.txt
EXPOSE 80
CMD ["python", "main.py"]

在要求.txt文件如下

^{pr2}$

错误如下。在

gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/local/include/python3.5m -c src/zbarlight/_zbarlight.c -o build/temp.linux-x86_64-3.5/src/zbarlight/_zbarlight.o -std=c99
src/zbarlight/_zbarlight.c:3:18: fatal error: zbar.h: No such file or directory
 #include <zbar.h>
                  ^
compilation terminated.
error: command 'gcc' failed with exit status 1

然后我通过本地安装libzbar dev

sudo apt-get install libzbar-dev

然后在本地尝试以下命令。在

dpkg -L libzbar-dev

对上述命令的响应

/.
/usr
/usr/share
/usr/share/doc
/usr/share/doc/libzbar-dev
/usr/share/doc/libzbar-dev/copyright
/usr/include
/usr/include/zbar.h
/usr/include/zbar
/usr/include/zbar/Image.h
/usr/include/zbar/Processor.h
/usr/include/zbar/Symbol.h
/usr/include/zbar/Decoder.h
/usr/include/zbar/Scanner.h
/usr/include/zbar/Exception.h
/usr/include/zbar/Video.h
/usr/include/zbar/Window.h
/usr/include/zbar/ImageScanner.h
/usr/lib
/usr/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu/libzbar.a
/usr/lib/x86_64-linux-gnu/pkgconfig
/usr/lib/x86_64-linux-gnu/pkgconfig/zbar.pc
/usr/share/doc/libzbar-dev/changelog.Debian.gz
/usr/lib/x86_64-linux-gnu/libzbar.so

第二个命令

ls -l /usr/include/zbar.h

上述命令的响应。在

-rw-r--r-- 1 root root 47339 Jan 28  2016 /usr/include/zbar.h

然后在Dockerfile中添加前两行。在

FROM ubuntu:16.04
RUN apt-get update; apt-get install -yV libzbar0 libzbar-dev; dpkg -L libzbar-dev; ls -l /usr/include/zbar.h; apt-get update
FROM python:3.5
WORKDIR /app
ADD . /app
RUN pip install -r requirements.txt
EXPOSE 80
CMD ["python", "main.py"]

在构建docker图像时很少有重要的屏幕截图。在

Responses : dpkg -L libzbar-dev & ls -l /usr/include/zbar.h

The Final Error


Tags: installdevgnuappsharegetincludelinux
1条回答
网友
1楼 · 发布于 2024-09-28 21:03:33

我修改了我的Dockerfile如下。在

FROM ubuntu:16.04
RUN apt-get update
RUN apt-get install -y zbar-tools libzbar-dev python-zbar
RUN dpkg -L libzbar-dev; ls -l /usr/include/zbar.h
RUN apt-get update
RUN apt-get install -y python3.5
WORKDIR /app
ADD . /app
RUN rm /usr/bin/python
RUN ln -s /usr/bin/python3.5 /usr/bin/python
RUN apt-get install -y python3-pip
RUN apt-get install -y python3-venv
RUN pip3 install -r requirements.txt
EXPOSE 80
CMD ["python", "main.py"]

当我改变主意使用python3.5的官方Docker映像时,我将Python作为一个包安装。 并更改了默认的python版本(modified soft link)。在

相关问题 更多 >