Adding to all the answers already available for this question, I would like to add the steps I followed to install Python3 on AWS EC2 instance running CentOS 7. You can find the entire details at this link.
https://aws-labs.com/install-python-3-centos-7-2/
First, we need to enable SCL. SCL is a community project that allows you to build, install, and use multiple versions of software on the same system, without affecting system default packages.
sudo yum install centos-release-scl
Now that we have SCL repository, we can install the python3
sudo yum install rh-python36
To access Python 3.6 you need to launch a new shell instance using the Software Collection scl tool:
scl enable rh-python36 bash
If you check the Python version now you’ll notice that Python 3.6 is the default version
python --version
It is important to point out that Python 3.6 is the default Python version only in this shell session. If you exit the session or open a new session from another terminal Python 2.7 will be the default Python version.
Now, Install the python development tools by typing:
sudo yum groupinstall ‘Development Tools’
Now create a virtual environment so that the default python packages don't get messed up.
mkdir ~/my_new_project
cd ~/my_new_project
python -m venv my_project_venv
To use this virtual environment,
source my_project_venv/bin/activate
Now, you have your virtual environment set up with python3.