首先查看当前系统中的python版本
1、安装开发工具
yum groupinstall " Development tools "
2、安装其它需要的包
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel
3、下载并解压缩 Python2.7.3
wget http: // python . org / ftp / python / 2.7 . 3 / Python- 2.7 . 3 . tar . bz2 tar -jxvf Python- 2.7 . 3 . tar . bz2
4、编译安装
cd Python- 2.7 . 3 ./ configure make&&make install
5、查看python2.7版本
接下来就可以使用python2.7来执行相应的python语句。
至此所有安装工作完成!
ps:如果想更完美一些,将系统默认的python指向2.7版本,执行以下命令:
mv / usr / bin / python / usr / bin / python2 . 6.6 ln -s / usr / local / bin / python2 . 7 / usr / bin / python
由于yum依赖python2.6.6才能正常工作,必须对其进行修改
vi / usr / bin / yum
将文件头部的
#!/usr/bin/python
改成
#!/usr/bin/python2.6.6