pyenv install build failed error Mac OS

Mac에 pyenv는 정상적으로 설치했다. pyenv 설치 후 특정 version의 python을 설치하려고 다음과 같은 명령 수행 시 BUILD FAILED 에러 발생했다.

$pyenv install 3.5.3
python-build: use openssl@1.1 from homebrew
python-build: use readline from homebrew
Downloading Python-3.5.3.tar.xz...
-> https://www.python.org/ftp/python/3.5.3/Python-3.5.3.tar.xz
error: failed to download Python-3.5.3.tar.xz

BUILD FAILED (OS X 10.14.6 using python-build 20180424)

에러를 자세히 보기 위해 -v 옵션을 사용했더니 다음과 같은 내용들이 출력됐다.

$ pyenv install -v 3.5.3
python-build: use openssl@1.1 from homebrew
python-build: use readline from homebrew
/var/folders/cb/hj031cjn06v25qv773t8s7qm0000gn/T/python-build.20200103104702.95942 ~/010_dev
Downloading Python-3.5.3.tar.xz...
-> https://www.python.org/ftp/python/3.5.3/Python-3.5.3.tar.xz
curl: (60) SSL certificate problem: Untrusted root certificate
More details here: https://curl.haxx.se/docs/sslcerts.html

curl performs SSL certificate verification by default, using a "bundle"
 of Certificate Authority (CA) public keys (CA certs). If the default
 bundle file isn't adequate, you can specify an alternate file
 using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in
 the bundle, the certificate verification probably failed due to a
 problem with the certificate (it might be expired, or the name might
 not match the domain name in the URL).
If you'd like to turn off curl's verification of the certificate, use
 the -k (or --insecure) option.
error: failed to download Python-3.5.3.tar.xz

BUILD FAILED (OS X 10.14.6 using python-build 20180424)

“curl: (60) SSL certificate problem: Untrusted root certificate” 에러를 검색했더니 다음과 같은 이유라고 나왔다. (참고 : 링크)

curl 은 기본적으로 https 사이트의 SSL 인증서를 검증한다. 인증 기관의 인증서 목록이 없거나 모르는 기관에서 발급한 인증서일 경우 다음과 같은 인증서 검증 에러를 발생시키고 동작을 중지하게 된다.

Curl 버전을 확인해보니 7.53.1 이다.

$ curl --version
curl 7.53.1 (universal-apple-darwin8.8.0+) libcurl/7.53.1 SecureTransport zlib/1.2.11
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: AsynchDNS IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz UnixSockets

Curl 업데이트를 위해 brew 명령을 사용했다.

$ brew reinstall curl

==> Reinstalling curl
==> Downloading https://homebrew.bintray.com/bottles/curl-7.67.0.mojave.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/3e/3e1fa3e2435503c0d67b447a4f20294459f90bc9279890ac80590617fe23657b?__gda__=exp=1578017153~hmac=dd06cfef44fce2d58c400e80c7089d0e4dc438cf2103f2bd28d11a49a1eace
######################################################################## 100.0%
==> Pouring curl-7.67.0.mojave.bottle.tar.gz
==> Caveats
curl is keg-only, which means it was not symlinked into /usr/local,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.

If you need to have curl first in your PATH run:
  echo 'export PATH="/usr/local/opt/curl/bin:$PATH"' >> ~/.bash_profile

For compilers to find curl you may need to set:
  export LDFLAGS="-L/usr/local/opt/curl/lib"
  export CPPFLAGS="-I/usr/local/opt/curl/include"

For pkg-config to find curl you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/curl/lib/pkgconfig"


zsh completions have been installed to:
  /usr/local/opt/curl/share/zsh/site-functions
==> Summary
?  /usr/local/Cellar/curl/7.67.0: 457 files, 3.2MB

설치 후 바로 새 버전이 적용되는 것은 아니다. 위 설명대로 다음과 같이 export를 해주고 source 명령으로 환경설정을 다시한다.

$ echo 'export PATH="/usr/local/opt/curl/bin:$PATH"' >> ~/.bash_profile
$ source ~/.bash_profile
$ curl --version
curl 7.67.0 (x86_64-apple-darwin18.7.0) libcurl/7.67.0 SecureTransport zlib/1.2.11
Release-Date: 2019-11-06
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: AsynchDNS IPv6 Largefile libz NTLM NTLM_WB SSL UnixSockets

이렇게 하면 python이 오류 없이 설치 되는 것을 확인할 수 있다.

$ pyenv install 3.5.3
python-build: use openssl@1.1 from homebrew
python-build: use readline from homebrew
Downloading Python-3.5.3.tar.xz...
-> https://www.python.org/ftp/python/3.5.3/Python-3.5.3.tar.xz
Installing Python-3.5.3...
python-build: use readline from homebrew
python-build: use zlib from xcode sdk
Installed Python-3.5.3 to /Users/victor/.pyenv/versions/3.5.3

Leave a Reply