pyenv

    Check version of linux πŸ”—

    uname -a
    

    Install prerequisites πŸ”—

    Source: https://github.com/pyenv/pyenv/wiki

    sudo apt update && sudo apt install make build-essential libssl-dev zlib1g-dev \
    libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm \
    libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev
    

    Run installer πŸ”—

    Source: https://github.com/pyenv/pyenv-installer

    curl https://pyenv.run | bash
    

    Update bashrc πŸ”—

    Add the following lines to bashrc

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

    List versions available for install πŸ”—

    Source: https://realpython.com/intro-to-pyenv/#using-pyenv-to-install-python

    Can also be filtered with grep like in the example

    pyenv install --list | grep " 3\.[678]"
    

    Install new version πŸ”—

    Source: https://github.com/pyenv/pyenv#usage

    pyenv install <version>