pyenv 安裝教學
2024, May 10
pyenv 安裝教學
Mac
- 下載 pyenv
curl https://pyenv.run | bash
- 跑完之後會出現類似以下的提示,請你加入到 ~/.bashrc 或是 ~/.zprofile:
export PATH="$HOME/.pyenv/bin:$PATH" eval "$(pyenv init -)" eval "$(pyenv virtualenv-init -)"
- 重開 terminal,檢查是否安裝成功
pyenv versions
Linux
1.先更新套件和安裝相關依賴
yum update
yum install gcc zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel openssl-devel tk-devel libffi-devel xz-devel
2.從 GitHub 上下載 pyenv
git clone https://github.com/pyenv/pyenv.git ~/.pyenv
3.在 ~/.bashrc 加入相關路徑和 pyenv init
echo ‘export PYENV_ROOT=”$HOME/.pyenv”’ » ~/.bashrc
echo ‘export PATH=”$PYENV_ROOT/bin:$PATH”’ » ~/.bashrc
echo -e ‘if command -v pyenv 1>/dev/null 2>&1; then\n eval “$(pyenv init -)”\nfi’ » ~/.bashrc
4.重新執行 shell,讓設定生效
exec “$SHELL”
5.確認是否有安裝成功
pyenv versions