Install latest python version with pyenv Install latest python version with pyenv python python

Install latest python version with pyenv


Try https://github.com/momo-lab/pyenv-install-latest

Installation...

git clone https://github.com/momo-lab/pyenv-install-latest.git "$(pyenv root)"/plugins/pyenv-install-latest

Latest 2.7 build of python...

pyenv install-latest 2.7

and for python 3...

pyenv install-latest


The following is a little shorter than your suggested "hack" and assumes you don't want versions like 3.5.0b1.

pyenv install $(pyenv install --list | grep -v - | grep -v b | tail -1)


Combining this with this answer, another option is:

pyenv install --list | grep --extended-regexp "^\s*[0-9][0-9.]*[0-9]\s*$" | tail -1

The regex looks for lines that start with a number ^[0-9], followed by any amount of dots and/or numbers [0-9.]*, and end with a number [0-9]$. Leading ^\s* or trailing \s*$ whitespaces may occur but don't have to.

Edit: to install:

pyenv install $(pyenv install --list | grep --extended-regexp "^\s*[0-9][0-9.]*[0-9]\s*$" | tail -1)