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
질문됨 2달 전842회 조회
2개 답변
2
수락된 답변

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
전문가
답변함 2달 전
profile picture
전문가
검토됨 2달 전
profile pictureAWS
전문가
검토됨 2달 전
  • 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
전문가
iBehr
답변함 2달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠