[Python] Pip로 패키지 설치할 때 SSL 인증 에러 뜰 경우

    에러 화면

    D:\Project\stable-diffusion-webui\venv\Scripts>pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu117
    Looking in indexes: https://download.pytorch.org/whl/cu117
    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: unable to get local issuer certificate (_ssl.c:997)'))': /whl/cu117/torch/
    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: unable to get local issuer certificate (_ssl.c:997)'))': /whl/cu117/torch/
    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: unable to get local issuer certificate (_ssl.c:997)'))': /whl/cu117/torch/

     

    위 화면은 pipi로 pytorch를 설치하다가 발생한 에러입니다. 이와같이 pip로 패키지를 설치할 때 SSL 인증 에러가 자주 발생하게 되는데요. 이럴때에는 아래와 같은 조치로 금방해결이 가능합니다.

     

    trusted-host URL

     

    위와 같이 trusted-host를 추가하게 되면 사이트가 신뢰가 되었다고 우리가 지정할 수 있습니다. 위 사이트의 경우 https://download.pytorch.org/whl/cu117 이기 때문에 download.pytorch.org를 신뢰 사이트로 지정하면 됩니다. 

     

    해결화면

    D:\Project\stable-diffusion-webui\venv\Scripts>pip3 install --trusted-host download.pytorch.org torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu117
    Looking in indexes: https://download.pytorch.org/whl/cu117
    Collecting torch
      Downloading https://download.pytorch.org/whl/cu117/torch-2.0.0%2Bcu117-cp310-cp310-win_amd64.whl (2343.6 MB)
         ---------------------------------------- 2.3/2.3 GB 638.8 kB/s eta 0:00:00
    Collecting torchvision
      Downloading https://download.pytorch.org/whl/cu117/torchvision-0.15.1%2Bcu117-cp310-cp310-win_amd64.whl (4.9 MB)
         ---------------------------------------- 4.9/4.9 MB 3.4 MB/s eta 0:00:00
    Collecting torchaudio
      Downloading https://download.pytorch.org/whl/cu117/torchaudio-2.0.1%2Bcu117-cp310-cp310-win_amd64.whl (2.5 MB)
         ---------------------------------------- 2.5/2.5 MB 2.9 MB/s eta 0:00:00
    Collecting networkx
      Downloading https://download.pytorch.org/whl/networkx-3.0-py3-none-any.whl (2.0 MB)
         ---------------------------------------- 2.0/2.0 MB 2.8 MB/s eta 0:00:00
    Collecting typing-extensions
      Downloading https://download.pytorch.org/whl/typing_extensions-4.4.0-py3-none-any.whl (26 kB)
    Collecting sympy
      Downloading https://download.pytorch.org/whl/sympy-1.11.1-py3-none-any.whl (6.5 MB)
         ---------------------------------------- 6.5/6.5 MB 8.4 MB/s eta 0:00:00
    Collecting filelock
      Downloading https://download.pytorch.org/whl/filelock-3.9.0-py3-none-any.whl (9.7 kB)
    Collecting jinja2
      Downloading https://download.pytorch.org/whl/Jinja2-3.1.2-py3-none-any.whl (133 kB)
         ---------------------------------------- 133.1/133.1 kB 280.5 kB/s eta 0:00:00
    Collecting pillow!=8.3.*,>=5.3.0
      Downloading https://download.pytorch.org/whl/Pillow-9.3.0-cp310-cp310-win_amd64.whl (2.5 MB)
         ---------------------------------------- 2.5/2.5 MB 2.5 MB/s eta 0:00:00
    Collecting numpy
      Downloading https://download.pytorch.org/whl/numpy-1.24.1-cp310-cp310-win_amd64.whl (14.8 MB)
         ---------------------------------------- 14.8/14.8 MB 3.5 MB/s eta 0:00:00
    Collecting requests
      Downloading https://download.pytorch.org/whl/requests-2.28.1-py3-none-any.whl (62 kB)
         ---------------------------------------- 62.8/62.8 kB 3.3 MB/s eta 0:00:00
    Collecting MarkupSafe>=2.0
      Downloading https://download.pytorch.org/whl/MarkupSafe-2.1.2-cp310-cp310-win_amd64.whl (16 kB)
    Collecting certifi>=2017.4.17
      Downloading https://download.pytorch.org/whl/certifi-2022.12.7-py3-none-any.whl (155 kB)
         ---------------------------------------- 155.3/155.3 kB 4.7 MB/s eta 0:00:00
    Collecting urllib3<1.27,>=1.21.1
      Downloading https://download.pytorch.org/whl/urllib3-1.26.13-py2.py3-none-any.whl (140 kB)
         ---------------------------------------- 140.6/140.6 kB 8.7 MB/s eta 0:00:00
    Collecting idna<4,>=2.5
      Downloading https://download.pytorch.org/whl/idna-3.4-py3-none-any.whl (61 kB)
         ---------------------------------------- 61.5/61.5 kB 3.4 MB/s eta 0:00:00
    Collecting charset-normalizer<3,>=2
      Downloading https://download.pytorch.org/whl/charset_normalizer-2.1.1-py3-none-any.whl (39 kB)
    Collecting mpmath>=0.19
      Downloading https://download.pytorch.org/whl/mpmath-1.2.1-py3-none-any.whl (532 kB)
         ---------------------------------------- 532.6/532.6 kB 11.1 MB/s eta 0:00:00
    Installing collected packages: mpmath, urllib3, typing-extensions, sympy, pillow, numpy, networkx, MarkupSafe, idna, filelock, charset-normalizer, certifi, requests, jinja2, torch, torchvision, torchaudio

     

    참고자료

    [1] [Python] SSL: CERTIFICATE_VERIFY_FAILED, 조치방법 5가지

    [2] [Git] SSL certificate problem: unable to get local issuer certificate

    [3] [Java] javax.net.ssl.SSLHandshakeException

    반응형

    댓글

    Designed by JB FACTORY