본문 바로가기

개발/Python

[Python] pip install에서 SSLError SSLCertVerificationError

반응형

1. 문제 발생

 - pip install [라이브러리 명]

 - pip를 통한 라이브러리 설치시 SSL 에러 발생

WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1125)'))': /packages/2e/ed/3f3f6a1a8eac1f5e11c87dd19a633043660c72453f55012f58a15a011cdf/numpy-1.20.3-cp38-cp38-win_amd64.whl
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1125)'))': /packages/2e/ed/3f3f6a1a8eac1f5e11c87dd19a633043660c72453f55012f58a15a011cdf/numpy-1.20.3-cp38-cp38-win_amd64.whl
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1125)'))': /packages/2e/ed/3f3f6a1a8eac1f5e11c87dd19a633043660c72453f55012f58a15a011cdf/numpy-1.20.3-cp38-cp38-win_amd64.whl
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1125)'))': /packages/2e/ed/3f3f6a1a8eac1f5e11c87dd19a633043660c72453f55012f58a15a011cdf/numpy-1.20.3-cp38-cp38-win_amd64.whl
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1125)'))': /packages/2e/ed/3f3f6a1a8eac1f5e11c87dd19a633043660c72453f55012f58a15a011cdf/numpy-1.20.3-cp38-cp38-win_amd64.whl
ERROR: Could not install packages due to an OSError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Max retries exceeded with url: /packages/2e/ed/3f3f6a1a8eac1f5e11c87dd19a633043660c72453f55012f58a15a011cdf/numpy-1.20.3-cp38-cp38-win_amd64.whl (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1125)')))

 

2. 원인

 - 주로 사내 네트워크에서 발생하는 문제이며 등록된 신뢰할 수 있는 루트 인증 기관 중에 python을 설치하기 위한 도메인이 포함되지 않은 경우

 

3. 해결

 1) pip install 실행시 trusted-host 옵션에 두가지 host를 추가해준다

pip install --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --trusted-host pypi.org [라이브러리 명]

 2) Alias 등록 (~/.bashrc)

  - pip를 입력하면 pip --trusted-host pypi.org --trusted-host files.pythonhosted.org를 입력한 것 처럼 동작한다

alias pip='pip --trusted-host pypi.org --trusted-host files.pythonhosted.org'

 3) 신뢰할 수 있는 루트 인증 기관에 관련 도메인을 등록한다

  - 사내 네트워크를 이용하는 경우 1), 2) 방법이 현실적이다

 

 

 

반응형