gpt4 book ai didi

python - 如何在alpine容器中安装python2.6?

转载 作者:行者123 更新时间:2023-11-30 22:46:35 25 4
gpt4 key购买 nike

如何在alpine docker容器中安装python2.6。

我尝试从源代码安装,但出现编译错误。

其实我想在容器中安装Python2.6和Python2.7。这样我就可以在 Python2.6 和 Python2.7 上运行单元测试。请对此提出一些想法。

我已经在 alpine 容器中安装了 gcc 、 g++ 、 make ,然后执行了以下步骤。

wget https://www.python.org/ftp/python/2.6/Python-2.6.tgz
tar xvzf Python-2.6.tgz
cd Python-2.6
./configure
make

make 时出现此错误,

~/Python-2.6 # make
gcc -c -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I. -IInclude -I./Include -DPy_BUILD_CORE -o Modules/config.o Modules/config.c
gcc -c -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I. -IInclude -I./Include -DPy_BUILD_CORE -DPYTHONPATH='":plat-linux4:lib-tk:lib-old"' \
-DPREFIX='"/usr/local"' \
-DEXEC_PREFIX='"/usr/local"' \
-DVERSION='"2.6"' \
-DVPATH='""' \
-o Modules/getpath.o ./Modules/getpath.c
gcc -fno-strict-aliasing -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I. -IInclude -I./Include -DPy_BUILD_CORE -c ./Modules/posixmodule.c -o Modules/posixmodule.o
./Modules/posixmodule.c:6173:1: error: conflicting types for 'posix_close'
posix_close(PyObject *self, PyObject *args)
^
In file included from Include/Python.h:44:0,
from ./Modules/posixmodule.c:30:
/usr/include/unistd.h:38:5: note: previous declaration of 'posix_close' was here
int posix_close(int, int);
^
Makefile:1234: recipe for target 'Modules/posixmodule.o' failed
make: *** [Modules/posixmodule.o] Error 1

有人可以建议我如何解决这个问题吗?

最佳答案

Docker 有一个 official repos ,使用起来非常方便。方便的话,有一个python官方 repo 。它具有不同版本的Python(包括2.7)和不同的基础操作系统(包括alpine)的图像。我建议使用官方 2.7-alphine 图像并使用 its Dockerfile作为安装 python 2.6 的引用。

我还建议使用单独的图像,一个使用 python 2.6,一个使用 2.7,而不是将两者放在同一个图像中。这将有助于避免同时安装/配置两个不同版本的 python。

<小时/>

如果不查看 Dockerfile 的其余部分,很难判断为什么构建无法正常工作,但可以从构建依赖项开始。官方 Dockerfile 在 37-53 行添加了构建依赖项,该列表比您所说安装的依赖项有更多的依赖项。

关于python - 如何在alpine容器中安装python2.6?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40831145/

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