我正在尝试在 linux 容器内运行的 docker 中安装 pyodbc 但我收到以下错误
src/pyodbc.h:56:10: fatal error: sql.h: No such file or directory
#include <sql.h>
^~~~~~~
compilation terminated.
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Failed building wheel for pyodbc
这是我的码头文件
FROM mcr.microsoft.com/azure-functions/python:2.0
ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
AzureFunctionsJobHost__Logging__Console__IsEnabled=true
COPY . /home/site/wwwroot
FROM ubuntu
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && \
apt-get -y install gcc mono-mcs && \
rm -rf /var/lib/apt/lists/*
FROM python
RUN apt-get update && apt-get install -y python3-pip
# RUN /usr/bin/pip -r /home/site/wwwroot/requirements.txt
# WORKDIR /home/site/wwwroot
COPY --from=0 /home/site/wwwroot /home/site/wwwroot
RUN cd /home/site/wwwroot && pip install -r requirements.txt
注意:我要将代码推送到 linux 机器中的 azure functionapp
原文由 saranraj kumar 发布,翻译遵循 CC BY-SA 4.0 许可协议
我遇到了同样的问题,我在我的 docker 文件中添加了以下代码,它开始工作了。缺少 Microsoft docker 镜像
unixodbc-dev
,因此您需要使用以下命令单独安装。