Consider installing Python with Anaconda or Miniconda (I recommend Miniconda). Conda lets you manage different Python versions easily with virtual environments.
sudo wget -c https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
sudo chmod +x Miniconda3-latest-Linux-x86_64.sh
If you're using a shell other than bash, type:
conda init <SHELL_NAME> (Supported shells include: fish, tcsh, xonsh, zsh)
Close and open the terminal. Type
conda activate to activate the (base) conda environment.
Create a Python 3.9.5 environment, and name it whatever you like:
conda create -n myenv python=3.9.5
Once created, you can activate and use that Python environment:
conda activate myenv
When finished, you can deactivate your environment with:
Any packages you install with
conda will be local to whatever environment you're using, so you don't have to worry about package conflicts. Just don't install everything in your (base) environment, because anything installed in (base) will get copied to new conda environments you create.
Setting up Miniconda on Ubuntu
Conda Cheat Sheet