sar*_*mar 12 azure python-3.x docker docker-build azure-functions
我正在尝试在 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
Run Code Online (Sandbox Code Playgroud)
这是我的 dockerfile
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
Run Code Online (Sandbox Code Playgroud)
注意:我要把代码推送到linux机器上的azure functionapp
Kar*_* VK 14
我遇到了同样的问题,我在 docker 文件中添加了以下代码,然后它开始工作了。缺少 Microsoft docker 映像unixodbc-dev,因此您需要使用以下命令单独安装。
RUN apt-get update && apt-get install -y --no-install-recommends \
unixodbc-dev \
unixodbc \
libpq-dev
Run Code Online (Sandbox Code Playgroud)
小智 13
这是对我有用的设置:
# pull official base image
FROM python:3.9.2-slim-buster
# install system dependencies
RUN apt-get update \
&& apt-get -y install gcc \
&& apt-get -y install g++ \
&& apt-get -y install unixodbc unixodbc-dev \
&& apt-get clean
Run Code Online (Sandbox Code Playgroud)
并且 pyodbc 包安装成功。
错误是:
src/pyodbc.h:56:10: fatal error: sql.h: No such file or directory
#include <sql.h>
Run Code Online (Sandbox Code Playgroud)
这告诉您您丢失了一个文件sql.h。看着为PyODBC的文档,它似乎需要unixODBC的开发环境。
对于大多数主要发行版,上面的链接都有安装说明。您将需要更新 Dockerfile 以安装该unixodbc-dev软件包。
| 归档时间: |
|
| 查看次数: |
6892 次 |
| 最近记录: |