Server/Linux

centOs7 python SSL오류

하서기 2023. 12. 15. 14:27
728x90
반응형

간만에 python을 centos7에 파이썬 3.12를 설치하고 나서 

pip install을 하는 순간 SSL 모듈 오류가...

하...

아래와 같이 오류가!!

pip install pymysql
Defaulting to user installation because normal site-packages is not writeable
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pymysql/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pymysql/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pymysql/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pymysql/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pymysql/
Could not fetch URL https://pypi.org/simple/pymysql/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pymysql/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
ERROR: Could not find a version that satisfies the requirement pymysql (from versions: none)
ERROR: No matching distribution found for pymysql
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
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

 

블로그 검색 후 여러 방법을 찾아봤지만.

설치때 부터가 문제였다

설치시 ssl 라이브러리가 정상적으로 설치과 되어 있는지 꼭 확인 해보셔야 합니다.

설정 로그를 보니...

checking whether compiling and linking against OpenSSL works... yes
checking for --with-openssl-rpath...
checking whether OpenSSL provides required ssl module APIs... no
checking whether OpenSSL provides required hashlib module APIs... no

 

ssl module가 no;;;;

방법을 찾아보니...

 

파이썬 설치 전에 ssl 라이브러리 위치를 임포트 시켜주면 됨!!
만약  OpenSSL을 rpm으로 업데이트 하고 싶으면.

yum install epel-release
yum install openssl11 openssl11-devel

위의 명령어 실행... 가장 최신 버전은 아니지만 

21.3.25 기준으로 업데이트 되고 있음.

 

728x90

이후. 

export CFLAGS=$(pkg-config --cflags openssl11)
export LDFLAGS=$(pkg-config --libs openssl11)
./configure
make
sudo make install

위의 실행 명령어 대로 실행

반응형

configure 이후 로그를 보면 ssl부분이 yes로 바뀌었다..

checking whether compiling and linking against OpenSSL works... yes
checking for --with-openssl-rpath...
checking whether OpenSSL provides required ssl module APIs... yes
checking whether OpenSSL provides required hashlib module APIs... yes

 

설치까지 완료 후 pip install을 하면 정상적으로 구동이 된다.

 

 

728x90
반응형