In addition to all the answers already available to this question, I would like to add the steps that I took to install Python3 on an AWS EC2 instance running CentOS 7. All the details can be found here.
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 create, install, and use multiple versions of software on the same system without affecting the default system packages.
sudo yum install centos-release-scl
Now that we have the SCL repository, we can install python3
sudo yum install rh-python36
To access Python 3.6, you need to start a new shell instance using the Software Collection scl utility:
scl enable rh-python36 bash
If you check the Python version now, you will notice that Python 3.6 is the default version.
python --version
It is important to note that Python 3.6 is the default version of Python only in this shell session. If you exit a session or open a new session from another terminal, Python 2.7 will be the default version of Python.
Now install the Python development tools by typing:
sudo yum groupinstall 'Development Tools
Now create a virtual environment so that Python packages are not confused by default.
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 a virtual environment configured on python3.