I have installed pyenv and used it to install Python 3.8.1 I had Python 3.7.6 installed manually before.

I have set 3.8.1 as global and, as this version is now markered with *, it was taken into account. However, which python3 and python3 -V are still outputting the values of 3.7.6! I have restarted the shell, but, unfortunately, the outputs are still the same.

Is this as expected behaviour? How to switch it to 3.8.1 properly?

NB echo $PATH outputs


enter image description here

enter image description here

  • 1
    Please post your cat ~/.bash_profile output. – anki Feb 9 at 20:09
  • @ankii - added at the end of the question. I was using the zsh though, and there is no file for zsh in the root folder as far as I can see. – Yulia V Feb 9 at 20:17
  • 1
    Oh, I didn't know that(should have seen the tags) . user manual says modify ~/.zshrc instead of the bash_profile – anki Feb 9 at 20:19


Define environment variable PYENV_ROOT to point to the path where pyenv repo is cloned and add $PYENV_ROOT/bin to your $PATH for access to the pyenv command-line utility.

$ echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
$ echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile

Zsh note: Modify your ~/.zshrc file instead of ~/.bash_profile.


Add pyenv init to your shell to enable shims and autocompletion. Please make sure eval "$(pyenv init -)" is placed toward the end of the shell configuration file since it manipulates PATH during the initialization.

$ echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n  eval "$(pyenv init -)"\nfi' >> ~/.bash_profile

Restart Shell

exec "$SHELL"
| improve this answer | |

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .