python 3.12 on Amazon Linux 2023

0

I'm trying to build a container to run on ECS with Amazon Linux 2023 as the base image. I'd like to use Python 3.12 to run an application on the container, and I'm having a hard time getting the package manager (dnf) to find Python 3.12.

The line...

RUN dnf -y install python3.12

...in my dockerfile fails with the following error:

0.605 No match for argument: python3.12                                                                                                                                                                                                  
0.614 Error: Unable to find a match: python3.12   

How do I install Python 3.12 on Amazon Linux 2023 using dnf?

stu
posta 2 mesi fa842 visualizzazioni
2 Risposte
2
Risposta accettata

Why not try installing Python3.12 using pyenv as shown below?

FROM amazonlinux:2023

RUN dnf install -y git tar gcc \
                   zlib-devel bzip2-devel readline-devel \
                   sqlite sqlite-devel openssl-devel \
                   tk-devel libffi-devel xz-devel

RUN curl https://pyenv.run | bash && \
    echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc && \
    echo '[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc && \
    echo 'eval "$(pyenv init -)"' >> ~/.bashrc && \
    source ~/.bashrc && \
    pyenv install 3.12.4 && \
    pyenv global 3.12.4
profile picture
ESPERTO
con risposta 2 mesi fa
profile picture
ESPERTO
verificato 2 mesi fa
profile pictureAWS
ESPERTO
verificato 2 mesi fa
  • By the way, this method takes about 6 to 7 minutes to build. Once the build is complete, you can start the container from the image and check the Python version.

    [root@ip-172-31-33-20 ~]# docker build ./
    [+] Building 367.4s (7/7) FINISHED
    
    [root@ip-172-31-33-20 ~]# docker run -it 46dccd41afb4 /bin/bash
    bash-5.2#
    bash-5.2# python -V
    Python 3.12.4
    
0

Looks like python3.11 is the latest available in the repos.

dnf list | grep python3

https://docs.aws.amazon.com/linux/al2023/ug/python.html

profile pictureAWS
ESPERTO
iBehr
con risposta 2 mesi fa

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande