Cannot install pyodbc in docker and getting error command 'gcc' failed with exit status 1 Cannot install pyodbc in docker and getting error command 'gcc' failed with exit status 1 docker docker

Cannot install pyodbc in docker and getting error command 'gcc' failed with exit status 1


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 


The error is:

 src/pyodbc.h:56:10: fatal error: sql.h: No such file or directory   #include <sql.h>

This is telling you that you are missing a file sql.h. Looking at the documentation for PyODBC, it appears to require the UnixODBC development environment.

There are installation instructions at the above link for most major distributions. You will need to update your Dockerfile to install the unixodbc-dev package.


This link is also helpful, you are missing mandatory files to needed to install. Add the below command for Debain to Dockerfile , the link has all solutions

RUN apt-get update && apt-get install -y gcc unixodbc-dev

https://github.com/mkleehammer/pyodbc/issues/165