I'm trying install pyodbc in docker running inside linux container But I'm getting the following error
Click here to view the image
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
Here is my 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
Note: I'm going push the code to the azure functionapp in linux machine
This is the setup that worked for me:
# 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`
And the pyodbc package was installed successfully.
I had the same issue, I added the below code in my docker file, and it started working. Microsoft docker image is missing unixodbc-dev
, so you need to install separately using the below command.
RUN apt-get update && apt-get install -y --no-install-recommends \
unixodbc-dev \
unixodbc \
libpq-dev
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With