Docker在映像构建中不接受pyOBDC

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Docker在映像构建中不接受pyOBDC相关的知识,希望对你有一定的参考价值。

我正在尝试为我的python应用程序构建q docker映像。但是每次运行Docker构建时,都会出现下一个错误。

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

如果我从我的requirements.txt中删除pyODBC,它将生成而没有问题。我的requirements.txt包含:

Flask==1.1.1
pyodbc==4.0.27
matplotlib==3.1.1
fpdf==1.7.2
pandas==0.25.1
答案

我认为您必须安装:

sudo apt-get install unixodbc unixodbc-dev

在我们的Docker文件中。

以上是关于Docker在映像构建中不接受pyOBDC的主要内容,如果未能解决你的问题,请参考以下文章

在构建 Docker 映像时要求安装 Typescript

Docker:如何避免 Docker 容器中不允许的操作?

从多项目点网核心解决方案构建 Docker 映像

在构建时使用 docker-compose 将环境变量传递给 docker 映像

在 Visual Studio 中使用相同的 docker 文件构建 docker 映像的 Azure Pipeline 失败

MySQL 函数在“php:7.1”docker 镜像中不可用