https://github.com/pyenv/pyenv

Installation

git clone <https://github.com/pyenv/pyenv.git> ~/.pyenv
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(pyenv init -)"' >> ~/.bash_profile

Commands

# Lists all Python versions found in `$PYENV_ROOT/versions/*'.
pyenv versions

# List all available versions.
pyenv install -l

# Install a Python version using python-build.
pyenv install <version>

# Uninstall a specific Python version.
pyenv uninstall <version>

# Show the global Python version.
pyenv global

# Set the global Python version.
pyenv global <version>

# Show the local application-specific Python version.
pyenv local

# Set the local application-specific Python version.
pyenv local <version>

# Unset the local application-specific Python version.
pyenv local --unset