Cannot switch Python with pyenv

Cannot switch Python with pyenv

[July 2021]
If you see this message when running eval $(pyenv init -)

WARNING: `pyenv init -` no longer sets PATH.
Run `pyenv init` to see the necessary changes to make to your configuration.

you should check the message from pyenv init as the warning says, but in a nutshell, you can use eval $(pyenv init --path) instead.

And dont forget to accordingly update your ~/.bash_profile, ~/.zprofile, ~/.bashrc, ~/.zshrc or the like if necessary.

Try this: eval $(pyenv init -)


$ python -V
Python 2.7.9
mac:~ $ eval $(pyenv init -)
mac:~ $ python -V
Python 3.5.0

More info:

Cannot switch Python with pyenv

For me, this worked on MacOS with ZSH after installing via Homebrew:

echo eval $(pyenv init --path) >> ~/.zprofile

I initially had eval $(pyenv init -) inside of my ~/.zshrc file, but that didnt seem to work.
After following this guide: I remved the eval call from the .zshrc file and added it to the .zprofile file using the above command and after restarting terminal everything worked.

Leave a Reply

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