The default Python version is 2.6 on CentOS 6.8, which is toooo out-dated. Now compile and install Python 3.5:
cd /opt
mkdir python35
curl -O https://www.python.org/ftp/python/3.5.0/Python-3.5.0.tgz
tar xf Python-3.5.0.tgz
cd Python-3.5.0
./configure --prefix=/opt/python35
make
make install
The key is using --prefix
when ./configure
to specify where to install.
However, if you have no plan to remove Python 3 in the future,
it's unnecessary to add --prefix
option when running ./configure
.
Because Python executable will be installed as python3.5
and python3
,
which doesn't conflict with the default Python.
Note:
If there are errors during the compile process, try the following codes:
sudo yum install yum-utils
sudo yum-builddep python
See How to install Python3 on CentOS for details.
Ref:
https://unix.stackexchange.com/questions/2502/using-different-versions-of-python