在centos 6系统中安装python2.7

时间:2021-11-17 01:54:00

Install development tools

# yum groupinstall "Development tools"
# yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel

Download and install Python

# wget http://python.org/ftp/python/2.7.3/Python-2.7.3.tar.bz2
# tar xf Python-2.7.3.tar.bz2
# cd Python-2.7.3
# ./configure --prefix=/usr/local
# make && make altinstall
安装完毕:

/usr/local/bin/python2.7

这个时候yum是不能用的,因为它依赖的是系统自带的python2.6.6,需要处理一下。
 mv /usr/bin/python /usr/bin/python.bak
 ln -s /usr/local/bin/python2.7 /usr/bin/python

#vi /usr/bin/yum
#!/usr/bin/python --> #!/usr/bin/python-old #修改此处为2.6.6的位置,就可以继续使用yum了整个升级过程完成,可以使用Python2.7.3版本了。