Python

[Python] 라이브러리 설치(pip)시 SSLError(SSLCertVerificationError… 오류 해결방법

pip install selenium 명령어를 실행하여 셀레늄 라이브러리를 설치하는 과정에 오류가 발생되었다.

SSL 인증서 관련 오류가 발생하는데 오류 내용은 다음과 같다.

(venv) PS C:\Users\test\PycharmProjects\pythonProject> pip install selenium
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 verif
y failed: unable to get local issuer certificate (_ssl.c:1129)’))’: /simple/selenium/
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 verif
y failed: unable to get local issuer certificate (_ssl.c:1129)’))’: /simple/selenium/
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 verif
y failed: unable to get local issuer certificate (_ssl.c:1129)’))’: /simple/selenium/
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 verif
y failed: unable to get local issuer certificate (_ssl.c:1129)’))’: /simple/selenium/
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 verif
y failed: unable to get local issuer certificate (_ssl.c:1129)’))’: /simple/selenium/
Could not fetch URL https://pypi.org/simple/selenium/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host=’pypi.org’, port=443): Max retries exceeded with url: /simple/selenium/
(Caused by SSLError(SSLCertVerificationError(1, ‘[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)’))) – skipping
ERROR: Could not find a version that satisfies the requirement selenium (from versions: none)
ERROR: No matching distribution found for selenium
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(SSLCertVerificationError(1, ‘[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)’))) – skipping
(venv) PS C:\Users\test\PycharmProjects\pythonProject>


certifi 라이브러리 설치

오류 해결을 위해 pip install certifi 명령어를 실행하여 certifi 라이브러리 설치 시도를 하였지만 동일하게 SSL 인증서 관련 오류가 발생된다.

(venv) PS C:\Users\test\PycharmProjects\pythonProject> pip install certifi
Requirement already satisfied: certifi in c:\users\test\pycharmprojects\pythonproject\venv\lib\site-packages (2023.5.7)
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(SSLCertVerificationError(1, ‘[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)’))) – skipping
(venv) PS C:\Users\test\PycharmProjects\pythonProject>

pip install 명령어 실행시 SSL인증서 관련 오류 해결방법

라이브러리 설치를 위해 pip install 명령어에 아래와 같이 옵션을 추가해준 후 제일 뒤쪽에 설치하고자하는 라이브러리를 적어주고 실행하면 설치가 된다. pip install certifi 명령어를 실행하였지만 설치가 되지 않는다면 방화벽이 설치된 내부망에서 제약적인 인터넷 환경일 가능성이 높다. 대부분 이런 상황은 회사 네트워크 환경일 가능성이 크다.

pip install –trusted-host pypi.python.org –trusted-host files.pythonhosted.org –trusted-host pypi.org selenium

명령어 실행결과 로그는 다음과 같다.
(venv) PS C:\Users\test\PycharmProjects\pythonProject> pip install –trusted-host pypi.python.org –trusted-host files.pythonhosted.org –trusted-host pypi.org selenium
Collecting selenium
Downloading selenium-4.10.0-py3-none-any.whl (6.7 MB)
Collecting attrs>=20.1.0 (from trio~=0.17->selenium)
Downloading attrs-23.1.0-py3-none-any.whl (61 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 61.2/61.2 kB 3.2 MB/s eta 0:00:00
Collecting sortedcontainers (from trio~=0.17->selenium)
Downloading sortedcontainers-2.4.0-py2.py3-none-any.whl (29 kB)
Requirement already satisfied: idna in c:\users\test\pycharmprojects\pythonproject\venv\lib\site-packages (from trio~=0.17->selenium) (3.4)
Collecting outcome (from trio~=0.17->selenium)
Downloading outcome-1.2.0-py2.py3-none-any.whl (9.7 kB)
Collecting sniffio (from trio~=0.17->selenium)
Downloading sniffio-1.3.0-py3-none-any.whl (10 kB)
Collecting cffi>=1.14 (from trio~=0.17->selenium)
Downloading cffi-1.15.1-cp39-cp39-win_amd64.whl (179 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 179.1/179.1 kB 10.6 MB/s eta 0:00:00
Collecting exceptiongroup>=1.0.0rc9 (from trio~=0.17->selenium)
Downloading exceptiongroup-1.1.2-py3-none-any.whl (14 kB)
Collecting wsproto>=0.14 (from trio-websocket~=0.9->selenium)
Downloading wsproto-1.2.0-py3-none-any.whl (24 kB)
Collecting pysocks!=1.5.7,<2.0,>=1.5.6 (from urllib3[socks]<3,>=1.26->selenium)
Downloading PySocks-1.7.1-py3-none-any.whl (16 kB)
Collecting pycparser (from cffi>=1.14->trio~=0.17->selenium)
Downloading pycparser-2.21-py2.py3-none-any.whl (118 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 118.7/118.7 kB 6.8 MB/s eta 0:00:00
Collecting h11<1,>=0.9.0 (from wsproto>=0.14->trio-websocket~=0.9->selenium)
Downloading h11-0.14.0-py3-none-any.whl (58 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 58.3/58.3 kB 3.0 MB/s eta 0:00:00
Installing collected packages: sortedcontainers, sniffio, pysocks, pycparser, h11, exceptiongroup, attrs, wsproto, outcome, cffi, trio, trio-websocket, selenium
Successfully installed attrs-23.1.0 cffi-1.15.1 exceptiongroup-1.1.2 h11-0.14.0 outcome-1.2.0 pycparser-2.21 pysocks-1.7.1 selenium-4.10.0 sniffio-1.3.0 sortedcontainers-2.4.0 trio-0.22.2 trio-websocket-0
.10.3 wsproto-1.2.0

[notice] A new release of pip is available: 23.1.2 -> 23.2.1
[notice] To update, run: python.exe -m pip install –upgrade pip
(venv) PS C:\Users\test\PycharmProjects\pythonProject>

정상적으로 설치가 되었음을 확인할 수 있다.



pip 업그레이드시 동일한 오류가 발생하는 경우에도 아래와 같은 명령어로 실행하면 설치되니 참고!!

 python.exe -m pip install --upgrade pip  --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --trusted-host pypi.org
Requirement already satisfied: pip in c:\users\test\pycharmprojects\pythonproject\venv\lib\site-packages (23.1.2)
Collecting pip
  Using cached pip-23.2.1-py3-none-any.whl (2.1 MB)
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 23.1.2
    Uninstalling pip-23.1.2:
      Successfully uninstalled pip-23.1.2
Successfully installed pip-23.2.1

Leave a Reply

error: Content is protected !!