ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • Python 3.12 설치시 Openssl 모듈 버전 확인이 필요 합니다.
    Python 2024. 8. 5. 18:15
    728x90

    Python 3.12을 설치할 때 발생할 수 있는 오류 중 하나는 SSL 인증서와 관련된 문제입니다. 특히, pip 설치 시 다음과 같은 오류를 만날 수 있습니다:

    Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
    

    이 오류는 Python 설치 시 SSL 모듈이 제대로 구성되지 않았기 때문에 발생합니다. Python 3.12 설치 후 SSL 모듈이 제대로 작동하는지 확인하는 것이 중요합니다.

    다음은 AWSLinux 기반의 Docker Container 설치시 명령어입니다.

    from amazonlinux # 1
    
    RUN  yum update --security --bugfix -y # 2
    
    RUN yum groupinstall "Development Tools" -y # 3
    RUN yum install openssl11 openssl11-devel  libffi-devel bzip2-devel wget -y # 3 + opnessl 1.1.1 설치
    # 4
    WORKDIR /usr/src
    RUN wget https://www.python.org/ftp/python/3.12.2/Python-3.12.2.tgz 
    RUN  tar xzf Python-3.12.2.tgz 
    
    # 5 
    WORKDIR /usr/src/Python-3.12.2
    RUN ./configure --enable-optimizations
    RUN make -j 8
    RUN make altinstall
    
    RUN python3.12 --version # 6
    
    # 7
    RUN curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
    RUN python3.12 get-pip.py  --trusted-host=files.pythonhosted.org --trusted-host=pypi.org
    RUN pip3.12 --version
    
    # 8 
    RUN ln -s /usr/local/bin/python3.12 /usr/bin/python3 & \
        ln -s /usr/local/bin/pip3 /usr/bin/pip3
    
    # 9
    # datetime zone setting
    RUN date
    RUN mv /etc/localtime /etc/localtime_org
    RUN ln -s /usr/share/zoneinfo/Asia/Seoul /etc/localtime
    RUN date
    
    

    Dockerfile은 다음 작업을 수행합니다

    1. Amazon Linux 이미지를 사용하여 Docker 컨테이너를 생성합니다.
    2. 보안 및 버그 수정 업데이트를 수행합니다.
    3. 개발 도구 및 필요한 라이브러리를 설치합니다.
    4. Python 3.12 소스 코드를 다운로드하고 압축을 해제합니다.
    5. Python 3.12를 OpenSSL 지원과 함께 구성하고 컴파일합니다.
    6. Python 및 Pip의 버전을 확인하여 설치가 올바르게 되었는지 검증합니다.
    7. pip를 설치 하고 올바르게 설치 되었는지 검증합니다.
    8. Python과 Pip에 대한 심볼릭 링크를 생성하여 /usr/bin 디렉토리에서 사용할 수 있도록 설정합니다.
    9. 시간대를 설정하여 시스템 시간대를 Asia/Seoul로 변경합니다.

    이 Dockerfile을 사용하면 Python 3.12와 Pip을 포함한 개발 환경을 AWS Linux 기반의 Docker 컨테이너에서 설정할 수 있습니다.

    참고 자료

    Python 3.12의 SSL 모듈에 대한 더 자세한 내용은 공식 문서를 참고하세요. 이 문서에는 SSL 모듈의 다양한 기능과 설정 방법이 자세히 설명되어 있습니다.



    728x90
Designed by Tistory.