命令'/ bin / sh -c sudo pip3 install -r requirements.txt'返回非零代码:1

时间:2016-01-13 05:49:23

标签: python docker dockerfile

我遇到了构建Docker容器的问题。不完全确定我需要做什么。

Dockerfile

FROM ubuntu:14.04

RUN apt-get update \
&& apt-get install -y tar git curl nano wget dialog net-tools build-essential \
&& apt-get install --no-install-recommends -y -q python3 python3-pip python3-dev
ADD . /bot
WORKDIR /bot
RUN sudo pip3 install -r requirements.txt

CMD ["python3", "app.py"]

Requirements.txt

Flask==0.10.1
Jinja2==2.8
MarkupSafe==0.23
Werkzeug==0.11.3
itsdangerous==0.24
lxml==3.5.0
requests==2.9.1
uWSGI==2.0.12
wikiquote==0.1.2

错误

http://hastebin.com/ipatorezos.coffee

[编辑]这似乎可以解决问题。添加了其他输入。谢谢!

FROM ubuntu:14.04

RUN apt-get update \
    && apt-get install -y tar git curl nano wget dialog net-tools build-essential \
    && apt-get install --no-install-recommends -y -q python3 python3-pip python3-dev \
    && apt-get install -y libxml2-dev libxslt-dev python-dev zlib1g-dev
ADD . /bot
WORKDIR /bot
RUN pip3 install -r requirements.txt

CMD ["python3", "app.py"]

1 个答案:

答案 0 :(得分:1)

错误似乎在附近:

Using build configuration of libxslt
        building 'lxml.etree' extension
        x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC -Isrc/lxml/includes -I/usr/include/python3.4m -c src/lxml/lxml.etree.c -o build/temp.linux-x86_64-3.4/src/lxml/lxml.etree.o -w
        In file included from src/lxml/lxml.etree.c:323:0:
        src/lxml/includes/etree_defs.h:14:31: fatal error: libxml/xmlversion.h: No such file or directory
         #include "libxml/xmlversion.h"

从“How to install lxml on Ubuntu”添加到您的Dockerfile:

&& apt-get install libxml2-dev libxslt-dev python-dev zlib1g-dev

另外,make sure your VM has enough memory(如果是apt-get install fails)。

OP确认完整的apt-get命令为:

RUN apt-get update \
    && apt-get install -y tar git curl nano wget dialog net-tools build-essential \
    && apt-get install --no-install-recommends -y -q python3 python3-pip python3-dev \
    && apt-get install -y libxml2-dev libxslt-dev python-dev zlib1g-dev