- 下载安装包和依赖包
wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz
yum install -y gcc gcc-c++ zlib* make -y
- 解压安装
mkdir -p /usr/local/python3
tar -xzvf Python-3.6.1.tgz -C /opt
- 编辑编译安装
cd /opt/Python-3.6.1
./configure --prefix=/usr/local/python3 \
--with-ssl
make && make install
- 建立软链接,方便使用
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
- 设置python环境变量
echo "export PATH=$PATH:$HOME/bin:/usr/local/python3/bin" >> ~/.bash_profile
source ~/.bash_profile
- 测试
[root@cloud Python-3.6.1]# python3 -V
Python 3.6.1