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

짧은 설명

긴 설명

설치방법

1) Roestta2 설치

/usr/sbin/softwareupdate --install-rosetta너무 느리면 아래 명령어로 설치하세요
/usr/sbin/softwareupdate --install-rosetta agree-to-license

2) Homebrew for ARM설치

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

3) Homebrew for X86 설치

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>

4) Alias와 Path를 추가

# 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

5) Pyenv 설치

# 아래 명령어를 실행하면 Intel brew의 환경변수를 커널에 export 해줍니다.
eval "$(ibrew shellenv)"
# Intel brew로 Pyenv를 설치합니다.
ibrew install pyenv

Python 3.X 설치

arch -x86_64 pyenv install --patch 3.6.8 < <(curl -sSL https://github.com/python/cpython/commit/8ea6353.patch\?full_index\=1)

부가 설명

Arch

#아키텍쳐명 / 설명
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
chrisjune

chrisjune

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

More from Medium

Python script installed which is not on PATH.

Two Steps To Turn A Python Script Into A macOS Application Installer

Make phone calls from your browser using Twilio and Python

Getting Started with Kivy: How to Code Desktop and Mobile Apps with Python

Screen Shot 2022-03-09 at 2.27.30 PM.png