pyenv does not change python version on mac
Asked Answered
V

2

3

I installed pyenv on mac and have used the following commands to install the required python version:

pyenv install 3.8.0
pyenv global 3.8.0

I am using zsh and my zshrc file contains the following:

if command -v pyenv 1>/dev/null 2>&1; then
  eval "$(pyenv init -)"
fi

When I check the python version, I can still see the old system version i.e. 2.7.15 responded by the command:

python -V

Any thoughts on what I might be doing wrong?

I have tried bash as well. I did not see any pyenv references in my bashrc file.

Vomiturition answered 29/11, 2019 at 1:31 Comment(0)
F
5

Does it work if you restart your shell?

$ exec "$SHELL"

If yes then the problem is that zshenv is loaded too soon, you can add the following to .zprofile or .zshrc

if command -v pyenv 1>/dev/null 2>&1; then
  eval "$(pyenv init -)"
fi
Fimbria answered 29/12, 2019 at 12:26 Comment(1)
Just by running eval "$(pyenv init -)" on the same shell should also fix the problem. New shells should also follow the global setting. Thanks @ddayan!Terryterrye
B
0

I've run into this same situation with my system version on Mac not updating after running the pyenv commands. This is what worked for me (you need to reset your shell and pyenv after setting the command):

pyenv global 3.7.4
eval "$(pyenv init -)"
Blastomere answered 1/9, 2020 at 13:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.