docker - 码头工人 | 在 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 映像上,因为它被视为依赖项。但这不起作用。
解决方案
推荐阅读
- javascript - 在 Angular 中使用源映射生成生产版本 - CLI
- javascript - 烧瓶关闭闪烁消息
- python - 问题运行 gunicorn 以服务于烧瓶应用程序
- c++ - 使用赋值运算符将宏转换为函数调用
- cmake - 一个项目A依赖共享库B,B依赖C,A不依赖C,为什么需要在A的CMakelist.txt中找到find_package和targe_link C?
- regex - 针对正则表达式奇怪行为scala的模式匹配
- hibernate - 原生 SQL + Hibernate 多租户
- python - 在 python 子进程之间共享对象
- scala - 如何在 Scala 中使用 Cats 将 Option[A] 转换为 Either[String, B]?
- django - 在 django azure 网站中使用消息代理(RabbitMQ /Redis)