linuxherokupyodbcdjango-pyodbc

Heroku deployment and pyodbc


Ok so I have been trying for days to deploy on Heroku. I can't even upgrade my account on Heroku to ask the question of how to go about this.

I have a fully functioning emulated Django project on my computer. I initially used PythonAnywhere and loved it. Until I realized Braintree is not working and I can't load php, it is too restricted. I do have a ticked with them.

So I moved to Heroku. The issue with Heroku is I can not even load it onto the site. I have it hooked to my GitHub. Now I can not load it because it refuses to built because of pyodbc will not load. I know this is shown by sql.h not found when installing PyODBC on Heroku. I am starting a new topic, because it is older. That being said I tried everything on here.

I think part of the issue is that I do not have sudo access to either one of these. I tried logging in with su account my account password but apparently we do not have that access. I tried build packs on the Heroku, but they seem to not want to work for the pyodbc library. I also was thinking of an add on on Heroku, but then I would still have change a lot of code.

Is there either a for dummies way to fix this? My sister who has been a programmer for years can't get it to work. Then me who is new can't. So we have a large spectrum experience between us. Sorry for the rant I have literally spent over 40 hours trying to get this to deploy.

Running setup.py install for pyodbc: started
           Running setup.py install for pyodbc: finished with status 'error'
           ERROR: Command errored out with exit status 1:
            command: /app/.heroku/python/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ni8r2oow/pyodbc/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ni8r2oow/pyodbc/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-nkt15se7/install-record.txt --single-version-externally-managed --compile --install-headers /app/.heroku/python/include/python3.9/pyodbc
                cwd: /tmp/pip-install-ni8r2oow/pyodbc/
           Complete output (14 lines):
           running install
           running build
           running build_ext
           building 'pyodbc' extension
           creating build
           creating build/temp.linux-x86_64-3.9
           creating build/temp.linux-x86_64-3.9/src
           gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -DPYODBC_VERSION=4.0.30 -I/app/.heroku/python/include/python3.9 -c src/buffer.cpp -o build/temp.linux-x86_64-3.9/src/buffer.o -Wno-write-strings
           In file included from src/buffer.cpp:12:
           src/pyodbc.h:56:10: fatal error: sql.h: No such file or directory
              56 | #include <sql.h>
                 |          ^~~~~~~
           compilation terminated.
           error: command '/usr/bin/gcc' failed with exit code 1
           ----------------------------------------
       ERROR: Command errored out with exit status 1: /app/.heroku/python/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-ni8r2oow/pyodbc/setup.py'"'"'; __file__='"'"'/tmp/pip-install-ni8r2oow/pyodbc/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-nkt15se7/install-record.txt --single-version-externally-managed --compile --install-headers /app/.heroku/python/include/python3.9/pyodbc Check the logs for full command output.
 !     Push rejected, failed to compile Python app.
 !     Push failed

Solution

  • You need to install it with a Heroku buildpack:

    https://elements.heroku.com/buildpacks/matt-bertoncello/python-pyodbc-buildpack

    That’ll give you the underlying MSODBC driver for Linux you need for pyodbc and django-pyodbc.