Mac brew python3 설치 에러 (Error: An unexpected error occurred during the `brew link` step)


기본 맥북에 설치된 파이썬 2 버전이 아닌 3버전을 이용하기 위해서 파이썬3 버전을 설치를 시도했고 

Error: An unexpected error occurred during the `brew link` step

위와 같은 에러 메세지를 만나게 되었다. 

구글링을 해보니…

https://github.com/jakubroztocil/httpie/issues/645

해당 링크에 이미 깃헙 이슈가 있었다. 

설치 에러가 발생한 직후 brew doctor 명령어를 이용해보니 아래와 같은 방법을 알려주었다.

Please note that these warnings are just used to help the Homebrew maintainers

with debugging if you file an issue. If everything you use Homebrew for is

working fine: please don’t worry or file an issue; just ignore this. Thanks!

Warning: The following directories do not exist:

/usr/local/sbin

You should create these directories and change their ownership to your account.

  sudo mkdir -p /usr/local/sbin

  sudo chown -R $(whoami) /usr/local/sbin

Warning: You have unlinked kegs in your Cellar

Leaving kegs unlinked can lead to build-trouble and cause brews that depend on

those kegs to fail to run properly once built. Run `brew link` on these:

p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #ffffff; background-color: #224fbc} p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #ffffff; background-color: #224fbc; min-height: 13.0px} span.s1 {font-variant-ligatures: no-common-ligatures} span.s2 {font-variant-ligatures: no-common-ligatures; color: #cccb3c}

  python

이렇게해보니 아래와 같은 에러가 또 발생한다.

p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #ffffff; background-color: #224fbc} span.s1 {font-variant-ligatures: no-common-ligatures; color: #610001} span.s2 {font-variant-ligatures: no-common-ligatures}

Error: An unexpected error occurred during the `brew link` step

The formula built, but is not symlinked into /usr/local

Permission denied @ dir_s_mkdir - /usr/local/Frameworks/Python.framework

Error: Permission denied @ dir_s_mkdir - /usr/local/Frameworks/Python.framework

또 brew doctor를 해보았다.

p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #ffffff; background-color: #224fbc} p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #ffffff; background-color: #224fbc; min-height: 13.0px} span.s1 {font-variant-ligatures: no-common-ligatures} span.s2 {font-variant-ligatures: no-common-ligatures; color: #cccb3c}

HyungJuui-MacBook-Pro:key nhj7$ brew doctor

Please note that these warnings are just used to help the Homebrew maintainers

with debugging if you file an issue. If everything you use Homebrew for is

working fine: please don’t worry or file an issue; just ignore this. Thanks!

Warning: You have unlinked kegs in your Cellar

Leaving kegs unlinked can lead to build-trouble and cause brews that depend on

those kegs to fail to run properly once built. Run `brew link` on these:

  python

brew link python 을 해보았다. 

p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #ffffff; background-color: #224fbc} span.s1 {font-variant-ligatures: no-common-ligatures} span.s2 {font-variant-ligatures: no-common-ligatures; color: #610001}

HyungJuui-MacBook-Pro:key nhj7$ brew link python

Linking /usr/local/Cellar/python/3.7.2_2… Error: Permission denied @ dir_s_mkdir - /usr/local/Frameworks/Python.framework

HyungJuui-MacBook-Pro:key nhj7$ cd /usr/local/Frameworks/

저 폴더를 local 밑에 만들어주고 chown 으로 권한을 줘야 제대로 동작할 것 같아서 그대로 해보았다.

p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #ffffff; background-color: #224fbc} span.s1 {font-variant-ligatures: no-common-ligatures}

HyungJuui-MacBook-Pro:local nhj7sudochownRsudo chown -R(whoami) /usr/local/Frameworks/

HyungJuui-MacBook-Pro:local nhj7$ python3

Python 3.7.2 (default, Mar 10 2019, 00:10:56) 

[Clang 10.0.0 (clang-1000.11.45.5)] on darwin

Type “help”, “copyright”, “credits” or “license” for more information.

>>> 

>>> 

>>> exit

p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #ffffff; background-color: #224fbc} span.s1 {font-variant-ligatures: no-common-ligatures}

Use exit() or Ctrl-D (i.e. EOF) to exit

이제 성공했다. 

그냥 python을 쓰거나 기타 툴에서도 파이썬3을 쓰기 위해서 bash_profile에 등록시켜주었다. 

vi ~/bash_profile

alias python=‘python3’ <= 요 내용을 추가한 뒤 저장하고 닫는다. 

source ~/bash_profile <=프로파일을 다시 인식시켜준 뒤에… 

python -V로 확인해보니 파이썬3으로 잘 실행된다. ㅎㅎ

파이썬 3 설치 끝.



Written by@[namu]
모바일, 스마트폰, 금융, 재테크, 생활 정보 등