Deploying Dash app to Heroku with SQL server connection

Hi All,

I am trying to publish my dash app to heroku, the code works fine if it runs on the local server, however once I try to deploy it via “git push heroku master”, an error returns stating “no module pyodbc” (although I do not import in in my code), once I run a pip install pyodbc the push command returns multiple errors.

any help will be greatly appreciated.

What errors do you get after you install pyodbc?

Here follows the part that fails:

remote: Building wheel for pyodbc (setup.py): started
remote: Building wheel for pyodbc (setup.py): finished with status ‘error’
remote: ERROR: Command errored out with exit status 1:
remote: command: /app/.heroku/python/bin/python -u -c ‘import sys, setuptools, tokenize; sys.argv[0] = ‘"’"’/t
mp/pip-install-rcw1ff9n/pyodbc/setup.py’"’"’; file=’"’"’/tmp/pip-install-rcw1ff9n/pyodbc/setup.py’"’"’;f=getattr(tok
enize, ‘"’"‘open’"’"’, open)(file);code=f.read().replace(’"’"’\r\n’"’"’, ‘"’"’\n’"’"’);f.close();exec(compile(code,
file, ‘"’"‘exec’"’"’))’ bdist_wheel -d /tmp/pip-wheel-2vre4rcg
remote: cwd: /tmp/pip-install-rcw1ff9n/pyodbc/
remote: Complete output (16 lines):

remote: /app/.heroku/python/lib/python3.6/distutils/dist.py:261: UserWarning: Unknown distribution option: ‘lon
g_description_content_type’
remote: warnings.warn(msg)
remote: running bdist_wheel
remote: running build
remote: running build_ext
remote: building ‘pyodbc’ extension
remote: creating build
remote: creating build/temp.linux-x86_64-3.6
remote: creating build/temp.linux-x86_64-3.6/src
remote: gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -DPYODBC_VERSION=4.0
.30 -I/app/.heroku/python/include/python3.6m -c src/buffer.cpp -o build/temp.linux-x86_64-3.6/src/buffer.o -Wno-write-st
rings
remote: In file included from src/buffer.cpp:12:0:
remote: src/pyodbc.h:56:10: fatal error: sql.h: No such file or directory
remote: #include <sql.h>
remote: ^~~~~~~
remote: compilation terminated.
remote: error: command ‘gcc’ failed with exit status 1
remote: ----------------------------------------
remote: ERROR: Failed building wheel for pyodbc
remote: Running setup.py clean for pyodbc

Anyone able to help?

I’m not sure if this will resolve your issue, but hopefully it will steer you in the right direction. I’ve copied a section of my installation notes for RHEL7 below. These steps were required for pyodbc:

  1. Update YUM
    • sudo yum update -y

  2. Install Software Collections (SCL)
    https://www.softwarecollections.org/en/docs/
    • sudo yum install centos-release-scl

  3. Install Microsoft ODBC driver for SQL Server (Linux)
    https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server
    • sudo curl https://packages.microsoft.com/config/rhel/7/prod.repo > /etc/yum.repos.d/mssql-release.repo
    • sudo yum remove unixODBC-utf16 unixODBC-utf16-devel
    • sudo ACCEPT_EULA=Y yum install msodbcsql17
    • echo ‘export PATH="$PATH:/opt/mssql-tools/bin"’ >> ~/.bash_profile
    • echo ‘export PATH="$PATH:/opt/mssql-tools/bin"’ >> ~/.bashrc
    • source ~/.bashrc
    • sudo yum install unixODBC-devel

  4. Install GNU Compiler Collection
    • sudo yum install gcc-c++

Hi, @EhanGreens
Have you resolved this issue?
I also met this issue and hope anyone to help this.
Thanks in advance.