[转]在Linux CentOS 6.6上安装Python 2.7.9

在Linux CentOS 6.6上安装Python 2.7.9

查看python安装版本

python -V

[转]在Linux CentOS 6.6上安装Python 2.7.9

yum中最新的也是Python 2.6.6,所以只能下载Python 2.7.9的源代码自己编译安装。

操作步骤如下:

1)安装devtoolset

yum groupinstall "Development tools" -y

[转]在Linux CentOS 6.6上安装Python 2.7.9

2)安装编译Python需要的包包

yum install zlib-devel -y
yum install bzip2-devel -y
yum install openssl-devel -y
yum install ncurses-devel -y
yum install sqlite-devel -y

3)下载并解压Python 2.7.9的源代码

cd /data
wget --no-check-certificate https://www.python.org/ftp/python/2.7.9/Python-2.7.9.tar.xz
tar -xvf Python-2.7..tar.xz
cd Python-2.7.

4)编译与安装Python 2.7.9

./configure --prefix=/usr/local

[转]在Linux CentOS 6.6上安装Python 2.7.9

make && make altinstall

[转]在Linux CentOS 6.6上安装Python 2.7.9

5)将python命令指向Python 2.7.9

ln -s /usr/local/bin/python2.7 /usr/local/bin/python

[转]在Linux CentOS 6.6上安装Python 2.7.9

6)检查Python版本

sh   -- 进入shell
sh-4.1# python -V   --查看python版本
Python 2.7.9
exit  -- 退出shell

[转]在Linux CentOS 6.6上安装Python 2.7.9

7 ) 更新环境变量

python -V    --此时还是Python 2.6.6
source /etc/profile   --刷新环境变量
python -V    --变成Python 2.7.9

[转]在Linux CentOS 6.6上安装Python 2.7.9

【参考资料】

Installing python 2.7 on centos 6.3

上一篇:在Linux CentOS上编译并安装Clang 3.5.0


下一篇:Python 练习册