Install prerequisites and pyenv:
sudo apt install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python-openssl
curl https://pyenv.run | bash
Prepare the startup files by following the output instructions.
Install a specific python version:
pyenv install --list | grep " 3\.[678]"
pyenv install -v <version>
pyenv global/local/shell <version>
Delete a specific version:
pyenv uninstall <version>
Install a virtual environment:
pyenv virtualenv <python_version> <environment_name>
For more information please read: https://realpython.com/intro-to-pyenv/