0

I'm trying to build q docker image of my python application. But every time i run Docker built it gives the next error.

Building wheels for collected packages: pyodbc, matplotlib, fpdf, pandas, MarkupSafe
  Building wheel for pyodbc (setup.py): started
  Building wheel for pyodbc (setup.py): finished with status 'error'
  ERROR: Command errored out with exit status 1:
   command: /usr/local/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-_00fg6j6/pyodbc/setup.py'"'"'; __file__='"'"'/tmp/pip-install-_00fg6j6/pyodbc/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-gq580il1 --python-tag cp38
       cwd: /tmp/pip-install-_00fg6j6/pyodbc/
  Complete output (14 lines):
  running bdist_wheel
  running build
  running build_ext
  building 'pyodbc' extension
  creating build
  creating build/temp.linux-x86_64-3.8
  creating build/temp.linux-x86_64-3.8/src
  gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -DPYODBC_VERSION=4.0.27 -I/usr/local/include/python3.8 -c src/buffer.cpp -o build/temp.linux-x86_64-3.8/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
   #include <sql.h>
            ^~~~~~~
  compilation terminated.
  error: command 'gcc' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for pyodbc

If i remove pyODBC from my requirements.txt it builds without problem. My requirements.txt contains:

Flask==1.1.1
pyodbc==4.0.27
matplotlib==3.1.1
fpdf==1.7.2
pandas==0.25.1
applesomthing
  • 373
  • 3
  • 19
  • you'll need to install unixodbc-dev this is exact question https://stackoverflow.com/questions/2960339/unable-to-install-pyodbc-on-linux – nithin Nov 26 '19 at 09:57
  • Im om a windows envirement. i tried adding it to requirements.txt but it gives a error that it doesn't find any matching distribution for unixodbc-dev – applesomthing Nov 26 '19 at 10:13
  • You can run arbitrary commands in your Dockerfile (like the `apt-get install` commands from the linked question) by prefixing them with `RUN`. You don't need `sudo` in Docker since most things run as root anyways and it's easy enough to use Docker to become root when needed. – David Maze Nov 26 '19 at 12:06

1 Answers1

0

I think you have to install:

sudo apt-get install unixodbc unixodbc-dev

In our Docker file.

Magofoco
  • 4,461
  • 5
  • 28
  • 61