我想在docker中部署我的python项目,我在requirments.txt中写了lxml>=3.5.0
,因为项目需要lxml。这是我的停靠文件:
FROM gliderlabs/alpine:3.3
RUN set -x \
&& buildDeps='\
python-dev \
py-pip \
build-base \
' \
&& apk --update add python py-lxml $buildDeps \
&& rm -rf /var/cache/apk/* \
&& mkdir -p /app
ENV INSTALL_PATH /app
WORKDIR $INSTALL_PATH
COPY requirements-docker.txt ./
RUN pip install -r requirements.txt
COPY . .
RUN apk del --purge $buildDeps
ENTRYPOINT ["celery", "-A", "tasks", "worker", "-l", "info", "-B"]
我在将它部署到 docker 时得到了这个:
*********************************************************************************
Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed?
*********************************************************************************
error: command 'gcc' failed with exit status 1
----------------------------------------
Rolling back uninstall of lxml
我虽然是因为'python-dev'和'python-lxml',然后我像这样编辑了dockfile:
WORKDIR $INSTALL_PATH
COPY requirements-docker.txt ./
RUN apt-get build-dev python-lxml
RUN pip install -r requirements.txt
它不起作用,我得到另一个错误:
---> Running in 73201a0dcd59
/bin/sh: apt-get: not found
如何在 docker 中正确安装 lxml?
最佳答案
我在 RUN pip install -r requirements.txt
之前添加了 RUN apk add --update --no-cache g++ gcc libxslt-dev
并且它起作用了。
关于python - 如何在 docker 中安装 lxml,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35931579/