首页 > 解决方案 > 码头工人 | 在 Python 3.8 上安装 lxml 的问题

问题描述

我正在构建一个使用图像的 docker 容器。(uwsgi-nginx-flask) 这是基于 Alpine Linux 映像的。

此容器中可用的最新 python 版本是 python 3.8。我在 Python 3.9 上开发了我的烧瓶应用程序。python 包依赖项之一是lxml. 当我尝试安装它时,它会抛出下面给出的错误。

  cc -I/usr/include/libxml2 -c /tmp/xmlXPathInitnq3gdzvk.c -o tmp/xmlXPathInitnq3gdzvk.o
  unable to execute 'cc': No such file or directory
  *********************************************************************************
  Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed?
  *********************************************************************************
  error: command 'gcc' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for lxml

unable to execute 'cc': No such file or directory
*********************************************************************************
Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed?
*********************************************************************************
error: command 'gcc' failed with exit status 1

这是我的 Dockerfile

FROM tiangolo/uwsgi-nginx-flask:python3.8-alpine
RUN apk add libxml2-dev 
RUN apk --update add bash nano
RUN apk --update add --no-cache python3
RUN python --version
RUN mkdir -p /var/www/app/
RUN pip3 install --no-cache --upgrade pip setuptools
WORKDIR /var/www/app/
COPY . /var/www/app/
ENV STATIC_URL /static
ENV STATIC_PATH /var/www/app/static
RUN pip3 install -r requirements.txt

您可以看到我什至尝试安装libxml2在 alpine 映像上,因为它被视为依赖项。但这不起作用。

标签: dockerdockerfilelxmlalpine

解决方案


推荐阅读