python - Docker 在镜像构建中不接受 pyOBDC
问题描述
我正在尝试构建我的 python 应用程序的 q docker 映像。但是每次我运行 Docker built 它都会给出下一个错误。
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 文件中。
推荐阅读
- pipenv - 使用 pipenv 安装 ta-lib 返回错误
- javascript - 模态打开后如何执行功能?
- mysql - 为同一个表编写子查询以访问不同的记录
- apache-kafka-streams - 如何修复 KafkaStream 中的 RocksDBException 错误
- python - 为什么 toPandas() 会抛出错误,而 .show() 工作得很好?
- java - Room 如何验证数据完整性?数据库版本/哈希存储在哪里?
- jsp - 使用derby,netbeans和jsp在两列中添加值并存储到第三列?
- javascript - 查找 MongoDB 中是否存在用户名和电子邮件
- java - 输出中的第一行
- algorithm - 同时验证多个棋子在 2D 网格上的运动