The python environment on the newly built Tencent Cloud server is only 2.7, but many systems currently use python3.6 and above.
1. View python and dependencies
// 切换目录
cd /usr/bin/
// 查看python文件
ls python* // output: python python2 python2.7
// 查看依赖关系
ls -al python* // output: 发现python默认指向python2,python2指向python2.7
2. Download the source code and unzip it
// 创建并切换目录
mkdir /usr/local/python3
cd /usr/local/python3
// 下载源码压缩文件
wget https://www.python.org/ftp/python/3.6.3/Python-3.6.3.tgz
// 解压并查看当前目录
tar -xvf Python-3.6.3.tgz
ll // output: 生成名为Python-3.6.3的目录
3.Compile
// 切换目录
cd Python-3.6.3
// 创建编译规则
./configure --prefix=/usr/local/python3Dir
// 编译
make
make install
4. Check whether the installation is successful
// 检查版本
python3 -V // output: Python3.6.3
// 检查依赖关系
cd /usr/local/bin/
ls -al python*