[Python] M1 맥북에서 Python 설치하기

짧은 설명

긴 설명

3.9.1 is the first version of Python to support macOS 11 Big Sur. With Xcode 11 and later it is now possible to build “Universal 2” binaries which work on Apple Silicon.

/usr/sbin/softwareupdate --install-rosetta너무 느리면 아래 명령어로 설치하세요
/usr/sbin/softwareupdate --install-rosetta agree-to-license
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"# 안될경우 아래코드를 실행
arch -x86_64 zsh
cd /usr/local && mkdir homebrew
curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew
Homebrew 설치 스크립트, 환경에 따라 설치 경로가 다르다.
# Intel brew로 패키지를 설치해서 Rosetta2로 에뮬레이팅하려면 아래 명령어를 사용
arch -x86_64 /usr/local/homebrew/bin/brew install <package name>
# Mac brew로 패키지를 설치하려면 아래 명령어를 사용
/opt/homebrew/bin/brew install <package name>
# Alias
echo "ibrew='arch -x86_64 /usr/local/bin/brew'" >> ~/.zshrc
echo "mbrew='arch -arm64e /opt/homebrew/bin/brew'" >> ~/.zshrc
# Path 이렇게 설정하면 네이티브 패키지를 우선 찾고 없을 경우 인텔기반 버전을 찾습니다.
echo "export PATH=\"/usr/local/bin:$PATH\"" >> ~/.zshrc
echo "export PATH=\"/opt/homebrew/bin:$PATH\" >> ~/.zshrc
# 아래 명령어를 실행하면 Intel brew의 환경변수를 커널에 export 해줍니다.
eval "$(ibrew shellenv)"
# Intel brew로 Pyenv를 설치합니다.
ibrew install pyenv
arch -x86_64 pyenv install --patch 3.6.8 < <(curl -sSL https://github.com/python/cpython/commit/8ea6353.patch\?full_index\=1)
#아키텍쳐명 / 설명
i386 32-bit intel
x86_64 64-bit intel
x86_64h 64-bit intel (haswell)
arm64 64-bit arm
arm64e 64-bit arm (Apple Silicon)
(좌) Python3.6.8 버전 .configure / (우) Python 3.9.1 버전 .configure

참고자료

--

--

Blog https://chrisjune.dev Work for www.29cm.co.kr

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store