0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Pythonのバージョン管理にHomebrewとpyenvを使用する流れ

Last updated at Posted at 2025-05-08
homebrewの確認
brew -v
pyenvの確認
pyenv -v

Homebrewのインストール
/bin/bash -c 
"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
pyenvのインストール
brew install pyenv
権限の対応
#You should change the ownership of these directories to your user.
sudo chown -R <ユーザー名> /usr/local/share/zsh /usr/local/share/zsh/site-functions

# And make sure that your user has write permission.
chmod u+w /usr/local/share/zsh /usr/local/share/zsh/site-functions
シェルの環境変数などの定義を追加
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc
echo 'export PATH="$PYENV_ROOT/shims:$PATH"' >> ~/.zshrc
echo 'eval "$(pyenv init -)"' >> ~/.zshrc
source ~/.zshrc
pyenvのリスト確認
pyenv install --list
今回は3.12.10を使用
pyenv install 3.12.10
警告が出るので先にやっておいた方が良いライブラリインストール
brew install xz
バージョン確認
python --version
バージョンの選択
pyenv global <バージョン指定 x.xx.xx>
バージョンが変わらない場合の対応 パスの設定 
eval "$(pyenv init --path)"
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?