Skip to main content

(Solved) Pyodbc install fails


1 comment

  • George Birnbaum

    After debugging and testing with the PSH support team, I was able to get a passing build

    @matthias-van-woensel suggested utilizing brew for managing the dependencies, and following was my build set for this to work.

    After this post, I found a new flaw in my approach. I planned to use the Microsoft ODBC driver that is available via Debian package. This brought up the new concern of not being able to use Debian package managers in the PSH environment. I also had some troubles shipping the driver right in my repo, but the details below will mention how to debug the driver issues.

    I was not previous aware of FreeTDS. FreeTDS is an open source ODBC Sql Server driver.

    Fortunately, like the unixODBC driver manage, this driver is available through homebrew. Below is my final build hook step to install all dependancies to connect to a Sql Server instance from a PSH python container.

    Below is the .odbc.ini file I used to tell register my FreeTDS driver with unixODBC that pyodbc will register. Location of this file can suit your preference, but update your build hook to match any change in location.

    Final Build Hook:

    sh -c "$(curl -fsSL"
        echo 'eval $(/app/.linuxbrew/bin/brew shellenv)' >>~/.profile
        eval $(/app/.linuxbrew/bin/brew shellenv)
        brew analytics off
        brew install gcc
        brew install openssl
        brew install freetds
        brew install unixodbc
        odbcinst -i -d -f /app/.odbc.ini
        pipenv install --system --deploy
        mkdir .ssh


    Description	= TDS driver (Sybase/MS SQL)
    Driver		= /app/.linuxbrew/lib/

Please sign in to leave a comment.