How to update python version in Mac OS with pyenv?

Everyone knows about ‘pyenv’, but in Mac OS do it like this:

python -V (you can see Python 2.7.16)

pyenv install 3.7.5

pyenv global 3.7.5

python -V (you can see Python 2.7.16, again)

For fix it you have to update your ‘bash_profile’:

echo ‘eval “$(pyenv init -)”‘ >> ~/.bash_profile

source ~/.bash_profile

And if you use zsh:

echo ‘eval “$(pyenv init -)”‘ >> ~/.zshrc

source ~/.zshrc

If you plan install virtualenv and virtualenvwrapper after install it you have to do it:

echo ‘if which pyenv-virtualenv-init > /dev/null; then eval “$(pyenv virtualenv-init -)”; fi’ >> ~/.bash_profile

source ~/.bash_profile

echo ‘if which pyenv-virtualenv-init > /dev/null; then eval “$(pyenv virtualenv-init -)”; fi’ >> ~/.zshrc

source ~/.zshrc



Leave a Reply

Your email address will not be published. Required fields are marked *