python 'pip install' 실행 시 [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate 에러가 발생할 경우

증상

pip install chromedriver-binary-auto Collecting chromedriver-binary-auto
  Using cached chromedriver-binary-auto-0.1.1.tar.gz (4.3 kB)
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: chromedriver-binary-auto
  Building wheel for chromedriver-binary-auto (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /Users/gilbok-m1/codes/gitlab-mamikos/bugsnag-settler/venv/bin/python -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/lx/27lglhtx72zfq8yvktrk3zch0000gp/T/pip-install-g_eqgjtm/chromedriver-binary-auto_f77ba021cff64615a0d1a33a03f34844/setup.py'"'"'; __file__='"'"'/private/var/folders/lx/27lglhtx72zfq8yvktrk3zch0000gp/T/pip-install-g_eqgjtm/chromedriver-binary-auto_f77ba021cff64615a0d1a33a03f34844/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /private/var/folders/lx/27lglhtx72zfq8yvktrk3zch0000gp/T/pip-wheel-tcyqe_up
       cwd: /private/var/folders/lx/27lglhtx72zfq8yvktrk3zch0000gp/T/pip-install-g_eqgjtm/chromedriver-binary-auto_f77ba021cff64615a0d1a33a03f34844/
  Complete output (76 lines):
  running bdist_wheel
  running build
  running build_py
  Traceback (most recent call last):
    File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 1346, in do_open
      h.request(req.get_method(), req.selector, req.data, headers,
 (...중략...)
    File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 1389, in https_open
      return self.do_open(http.client.HTTPSConnection, req,
    File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/urllib/request.py", line 1349, in do_open
      raise URLError(err)
  urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)>
  

해결책

python 설치 경로의 Install Certificates.command 를 실행해 줍니다.

  • 제 경우 설치 경로는 Macintosh HD > Applications > Python 3.9 였습니다.
~ /Applications/Python\ 3.9/Install\ Certificates.command ; exit;
 -- pip install --upgrade certifi
Collecting certifi
  Using cached certifi-2021.10.8-py2.py3-none-any.whl (149 kB)
Installing collected packages: certifi
Successfully installed certifi-2021.10.8
 -- removing any existing file or link
 -- creating symlink to certifi certificate bundle
 -- setting permissions
 -- update complete
Saving session...completed.
Deleting expired sessions...       7 completed.

[Process completed]

이걸 실행한 후 거짓말처럼 에러가 사라졌습니다.

~ pip install chromedriver-binary-auto
Collecting chromedriver-binary-auto
  Using cached chromedriver-binary-auto-0.1.1.tar.gz (4.3 kB)
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: chromedriver-binary-auto
  Building wheel for chromedriver-binary-auto (setup.py) ... done
  Created wheel for chromedriver-binary-auto: filename=chromedriver_binary_auto-0.1.1-py3-none-any.whl size=8197116 sha256=111a82209f225575746591cb444bc64e6441d65ea3e426538a6e0337a61013fc
  Stored in directory: /Users/gilbok-m1/Library/Caches/pip/wheels/eb/af/a9/70002c837511468ee83aee68d1b42e029679e5b36ac1526341
Successfully built chromedriver-binary-auto
Installing collected packages: chromedriver-binary-auto
Successfully installed chromedriver-binary-auto-0.1.1

일찍 퇴근하세요.