How to install pyenv on Ubuntu
This is a short tutorial on installing pyenv on Ubuntu 20.04.
Pyenv is a python version management tool that you can use to switch between python versions with ease. If you use Pipenv (Pipfile) it can automatically install required python versions using the Pipfile too.

Step 1: Install required packages:
Copy and paste the following lines to your terminal
sudo apt-get update; sudo apt-get 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-devinstaller liblzma-dev
Step 2: Install Pyenv with the installer:
curl https://pyenv.run | bash
Step 3: Add these to your ~/.bashrc file. Basically adds pyenv to PATH and initializes pyenv
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
if command -v pyenv 1>/dev/null 2>&1; then
eval "$(pyenv init -)"
fi
eval "$(pyenv init -)"
Step 4: Update your current shell environment
source ~/.bashrc
Step 5: Install python
Install any python version you want using the following command. Replace the version number with the version you want to install.
pyenv install 3.6.9
Step 6: Setting global and local python versions
pyenv global 3.6.9
This command will set the global python version to 3.6.9 to set local python version use:
pyenv local 3.6.9
Use pyenv versions
command to list all versions of python you have installed!
Done!