Meysam
Meysam

Reputation: 18177

"pyenv versions" and "python -V" showing different versions

I need to use python 3.8. I installed it using the following command:

pyenv install 3.8.1

Now the output of pyenv versions is:

  system
* 3.8.1 (set by /Users/username/.pyenv/version)

Output of python -V:

Python 2.7.16

Why are they different?

Upvotes: 8

Views: 6996

Answers (2)

DalyaG
DalyaG

Reputation: 3117

I had the exact same issue after installing oh-my-zsh. What solved it for me was:

  1. Add pyenv to the plugins list on .zshrc:

    plugins=(git pyenv)
    
  2. Almost at the top of the file, just under these lines:

    # Path to your oh-my-zsh installation.
    export ZSH="$HOME/.oh-my-zsh"
    

    I added these lines:

    export PYENV_ROOT="$HOME/.pyenv"
    export PATH="$PYENV_ROOT/bin:$PATH"
    eval "$(pyenv init --path)"
    

And then I relaunched the terminal and everything was fine! (that is, the python version was the same)

Upvotes: 3

Chiel
Chiel

Reputation: 2179

Try eval "$(pyenv init --path)". That worked for me.

Upvotes: 10

Related Questions