Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"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?

like image 455
B Faley Avatar asked Jun 15 '26 23:06

B Faley


2 Answers

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

like image 70
Chiel Avatar answered Jun 18 '26 13:06

Chiel


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)

like image 26
DalyaG Avatar answered Jun 18 '26 11:06

DalyaG