๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

๐Ÿ‘ฉ๐Ÿป‍๐Ÿ’ป Programming/programming

[Django & ๊ฐ€์ƒํ™˜๊ฒฝ] pyenv ์„ค์น˜ ๋ฐ ํ™˜๊ฒฝ ์„ค์ •(feat.mac M1)

โ–ช๏ธError message

Django ๊ฐœ๋ฐœ ํ™˜๊ฒฝ ๊ตฌ์„ฑ์„ ์œ„ํ•ด pyenv, pyenv-virtualenv๋ฅผ ์„ค์น˜ํ•˜๋ ค๊ณ  ํ•˜์˜€์œผ๋‚˜ M1์ด๋ผ ๋‹ค์Œ๊ณผ ๊ฐ™์€ Error๋ฅผ ์ง๋ฉดํ•˜์˜€์Šต๋‹ˆ๋‹ค.

- ์—๋Ÿฌ ๋ฉ”์„ธ์ง€ ํ™•์ธ

Error: Cannot install under Rosetta 2 in ARM default prefix (/opt/homebrew)!
To rerun under ARM use:
    arch -arm64 brew install ...
To install under x86_64, install Homebrew into /usr/local.

 

์ฐธ๊ณ ๋กœ ์ œ mac์€ MacBook Pro(14ํ˜•, 2021๋…„ ๋ชจ๋ธ)๋กœ, Apple M1 Pro์นฉ์ด ๋‚ด์žฅ๋˜์–ด์žˆ์Šต๋‹ˆ๋‹ค.๐Ÿ™‚

 

my mac info


โ–ช๏ธsolution

๊ฐ„๋‹จํ•˜์ง€๋งŒ, ์—๋Ÿฌ๋ฉ”์„ธ์ง€์— ์ ํžŒ๋Œ€๋กœ ํ•˜์˜€์Šต๋‹ˆ๋‹ค(์นœ์ ˆํ•œ ํ„ฐ๋ฏธ๋„)

- ์„ค์น˜ํ•˜๋Š” ๋ช…๋ น์–ด

arch -arm64 brew install pyenv
arch -arm64 brew install pyenv-virtualenv

 

 

์„ค์น˜ ์™„๋ฃŒ


โ–ช๏ธpyenv ํ™˜๊ฒฝ ์„ค์ •

shell์—์„œ pyenv๋ช…๋ น์–ด๋ฅผ ์•Œ์•„๋“ค์„ ์ˆ˜ ์žˆ๋„๋ก path์— ์ถ”๊ฐ€ํ•˜๊ธฐ(shell ์ข…๋ฅ˜์— ๋”ฐ๋ผ ๋งž์ถ”์–ด ์„ค์ • ํ™•์ธ ํ•„์ˆ˜! โœจ)

- pyenv ์„ค์ •ํ•˜๊ธฐ for bash

echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.profile
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.profile
echo 'eval "$(pyenv init --path)"' >> ~/.profile
echo 'if [ -n "$PS1" -a -n "$BASH_VERSION" ]; then source ~/.bashrc; fi' >> ~/.profile
echo 'eval "$(pyenv init -)"' >> ~/.bashrc
echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc

- pyenv ์„ค์ •ํ•˜๊ธฐ for zsh

echo 'eval "$(pyenv init --path)"' >> ~/.zprofile
echo 'eval "$(pyenv init -)"' >> ~/.zshrc
echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.zshrc

โ–ช๏ธpyenv๋ฅผ ์ด์šฉํ•œ python ์„ค์น˜

- pyenv๋กœ ์„ค์น˜ ํ•  ์ˆ˜ ์žˆ๋Š” python ๋ฒ„์ „ ํ™•์ธ

pyenv install --list

- pyenv๋กœ ์„ค์น˜ ํ•  ์ˆ˜ ์žˆ๋Š” python ์„ค์น˜

M1์€ ๋‘๋ฒˆ์งธ ๋ช…๋ น์–ด๋กœ ํ•˜์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค! ๐Ÿ™‚

pyenv install 3.9.10
arch -arm64 pyenv install 3.9.10

- ์„ค์น˜๋œ python ๋ฒ„์ „ ํ™•์ธ

pyenv versions

์„ค์น˜ ์™„๋ฃŒ! Django ๋ฟŒ์ˆ˜๊ธฐ ๊ณ ๊ณ  ๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅ

 

์„ค์น˜ ์™„๋ฃŒ
์„ค์น˜ ํ›„ ๋ฒ„์ „ ํ™•์ธ