LoginSignup
17
7

More than 1 year has passed since last update.

pyenvでpythonのバージョンが反映されない時

Last updated at Posted at 2021-08-23

経緯

  • pyenvを入れたらgoogle sdkが動かなくなった。エラーの内容をみるとPythonのバージョンがどうもおかしいのでバージョンを確認したらsystemのデフォルトのバージョンが参照されていた。
% pyenv install --list
% pyenv local 3.7.9
% python -V 
Python 2.7.16

修正方法

  • ~/.zshrcまたは~/.bashrcへ書きを追記してsource ~/.zshrcまたはsource ~/.bashrcを実行

追記内容

  • pyenvをインストールすると勝手に追記されていると思いますが、私の環境下ではeval "$(pyenv init --path)"が追記されませんでした。
~/.zshrc
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init --path)" # これを追記
eval "$(pyenv init -)"
  • 反映してバージョンを確認
% source ~/.zshrc
% python --version           
Python 3.7.9
17
7
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
17
7