CentOS 6.8 安装 Python 2.7.12

CentOS 6.8自带的是Python 2.6,yum源中也是2.6,下面介绍如何安装2.7.12

操作步骤如下:

1)安装devtoolset

yum groupinstall “Development tools”

2)安装编译Python需要的包

yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel
3)下载并解压Python 2.7.12的源代码

cd /opt
wget –no-check-certificate https://www.python.org/ftp/python/2.7.12/Python-2.7.12.tar.xz
tar xf Python-2.7.12.tar.xz
cd Python-2.7.12

4)编译与安装Python 2.7.12
./configure –prefix=/usr/local
make && make altinstall

5)将python命令指向Python 2.7.12
ln -s /usr/local/bin/python2.7 /usr/local/bin/python

6)检查Python版本
python -V
Python 2.7.12

暂无评论

发表评论

电子邮件地址不会被公开。 必填项已用*标注