Skip to content

Instantly share code, notes, and snippets.

@yowmamasita
Last active August 26, 2023 05:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yowmamasita/64d06a212c1d20238a391df350d15d11 to your computer and use it in GitHub Desktop.
Save yowmamasita/64d06a212c1d20238a391df350d15d11 to your computer and use it in GitHub Desktop.
Install the latest version of CPython using pyenv in a single command
#!/bin/bash
# make sure you have pyenv
curl https://pyenv.run | bash
# works on ubuntu and mac
pyenv install $(pyenv install --list | egrep '^\s*[0-9]+\.[0-9]+\.[0-9]+$' | sort -Vr | head -n1 | tr -d '[:space:]')
# if you wish to use it globally
LATEST_PYTHON_VERSION=$(pyenv install --list | grep -v - | grep -v b | sort -Vr | head -n 1 | tr -d '[:space:]')
pyenv install $LATEST_PYTHON_VERSION
pyenv global $LATEST_PYTHON_VERSION
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment