gpt4 book ai didi

python - 错误 : command 'gcc' failed with exit status - while installing ibm_db on docker centos

转载 作者:行者123 更新时间:2023-12-04 19:40:53 26 4
gpt4 key购买 nike

我正在尝试安装 ibm_db - python3.6 但无法进行 pip 安装。在 python 2.7 上安装成功,但在 3.6 上它抛出 gcc 错误
docker 文件

RUN yum -y install python3
RUN yum install -y python34-devel python-devel centos-release-scl gcc libssl-dev openssl yum install gcc openssl-devel bzip2-devel libffi libffi-devel
RUN yum install -y python gcc gcc-c++ libgcc libstdc++ gnupg wget make git
RUN python --version
RUN which python
RUN pip --version
RUN python3 --version
RUN which python3
RUN pip3 --version

RUN python3.6 -m pip install -r scripts/requirements.txt
要求.txt
ibm_db==3.0.2
ibm-db-sa==0.3.5
SQLAlchemy==1.3.18
日志
08-Aug-2020 07:57:40        building 'ibm_db' extension
08-Aug-2020 07:57:40 creating build/temp.linux-x86_64-3.6
08-Aug-2020 07:57:40 gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -Iclidriver/include -I/usr/include/python3.6m -c ibm_db.c -o build/temp.linux-x86_64-3.6/ibm_db.o
08-Aug-2020 07:57:40 ibm_db.c:27:20: fatal error: Python.h: No such file or directory
08-Aug-2020 07:57:40 #include <Python.h>
08-Aug-2020 07:57:40 ^
08-Aug-2020 07:57:40 compilation terminated.
08-Aug-2020 07:57:40 error: command 'gcc' failed with exit status 1
08-Aug-2020 07:57:40
08-Aug-2020 07:57:40 ----------------------------------------
08-Aug-2020 07:57:40 Command "/usr/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-fvpot_ia/ibm-db/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-yrktaypy-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-fvpot_ia/ibm-db/
08-Aug-2020 07:57:42 The command '/bin/sh -c python3.6 -m pip install -r scripts/requirements.txt' returned a non-zero code: 1
08-Aug-2020 07:57:42 make: *** [build] Error 1

最佳答案

下面的 Dockerfile 是针对当前版本的 ibm_db 和 ibm_db_sa 以及 centos7 的 SQLAlchemy 的镜像。
它适用于 x64 架构,无需编译 ibm_db。
更改 Dockerfile 以省略镜像中不需要的包。较小的图像可以更快地构建并使用更少的存储空间。
此 Dockerfile 显示了复制预配置 db2dsdriver.cfg 的可选步骤。进入图像到默认位置。
这让我可以使用 db2cli在使用 python ibm_db 之前,在容器中确保与数据库的连接。
db2cli 需要 LD_LIBRARY_PATH 来包含 clidriver\lib 目录,以确保 db2cli validate 将运行。

 FROM centos:7


RUN yum install -y \
pam-devel \
pam.i686 \
libaio \
libstdc++-devel.i686 \
numactl-libs \
gcc \
gcc-c++ \
ksh \
numactl \
file \
kernel-devel \
vi \
sudo \
util-linux \
which \
openssh-clients \
zip \
unzip \
python3 \
python3-devel \
libssl_dev \
openssl \
openssl-devel \
bzip2-devel \
libffi \
libffi-devel \
libgcc \
wget \
make \
git \
libxml2 \
&& yum -y update \
&& yum clean all \
&& python3 -m pip install --upgrade pip \
&& python3 -m pip install ibm_db \
&& python3 -m pip install ibm_db_sa

ENV LD_LIBRARY_PATH="/usr/local/lib64/python3.6/site-packages/clidriver/lib:${LD_LIBRARY_PATH}"

# Optional - copy a preconfigured db2dsdriver.cfg to the image default location for db2cli to work
COPY db2dsdriver.cfg /usr/local/lib64/python3.6/site-packages/clidriver/cfg

关于python - 错误 : command 'gcc' failed with exit status - while installing ibm_db on docker centos,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63313136/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com