[Python] Installing python3.10 on debian:stretch-slim image?

Discussão em 'Python' iniciado por Stack, Maio 6, 2025.

  1. Stack

    Stack Membro Participativo

    I have an docker file where the base image is set to debian:stretch-slim. The default version of python3 is python3.5 in this image.

    FROM debian:stretch-slim as base-os

    .... ....

    RUN python3 -V
    RUN which python3


    Output is:

    #35 [linux/amd64 base-os 14/18] RUN python3 -V
    #35 0.132 Python 3.5.3


    I am trying to have python3.10 available in this image and have tried a couple of things and they are not working out so far.

    Approach 1:

    Manual download and install python3.10


    RUN wget https://www.python.org/ftp/python/3.10.0/Python-3.10.0.tgz
    RUN tar -xzf Python-3.10.0.tgz
    RUN cd Python-3.10.0 && ./configure --prefix=/usr/local \
    --enable-optimizations \
    --with-lto \
    --with-dbmliborder=bdb:gdbm \
    --with-ensurepip \
    'CFLAGS=-g -fstack-protector-strong -Wformat -Werror=format-security' \
    LDFLAGS="-Wl,-z,relro" \
    CPPFLAGS=-D_FORTIFY_SOURCE=2 && make -j 4 && make altinstall
    RUN rm -rf Python-3.10.0.tgz
    RUN rm -rf Python-3.10.0


    This approach 1 errors out with

    #44 255.8 Traceback (most recent call last):
    #44 255.8 File "<frozen zipimport>", line 570, in _get_decompress_func
    #44 255.8 ModuleNotFoundError: No module named 'zlib'
    Installing zlib again gives more errors and ends up in never ending problem.


    I tried to read through some links and looks like many has faced this problem but no clear solution has been listed anywhere. Can some expert shed his thoughts on it as to what is needed for python3.10?

    I have already listed the approaches that I tried.

    Continue reading...

Compartilhe esta Página