Centos 6.4 python 2.6升级到 2.7
python2.7.X下载安装
1.查看python的版本
[[email protected] ~]# python -V
Python 2.6.6
2.下载Python-2.7.8
[[email protected]]#wgethttp://python.org/ftp/python/2.7.8/Python-2.7.8.tgz
3.解压
[email protected] python]#tar xf Python-2.7.8.tgz
4.切换目录
[[email protected]]# cd /Python-2.7.8
5.安装
[[email protected]]# ./configure --prefix=/usr/local/python27
[[email protected]]#make
[[email protected]]# make install
最新2.7.8版本的python已经安装到了系统中,但是还没有完成
再次查看python版本,发现依然是2.6.6版本
[[email protected] ~]#python -V
Python 2.6.6
python多版本共存解决
1.把原来的python重命名成python_old,注意不要删除它
[[email protected]]# mv /usr/bin/python /usr/bin/python_old
2.建立新的python的软连接
[[email protected]]# ln -s /usr/local/python27/bin/python /usr/bin/
3. 再查看一下版本,发现ok
[[email protected] ~]#python -V
Python 2.7.8
至此我们已经可以正常使用python2.7.X
解决yum的python版本问题
但是我们还有最后一个问题要解决:但是因为yum是使用的python2.4的版本,所以,还需要修改一下(前面我们重命名的python_old现在派上用场)
[[email protected] ~]# yum
There was aproblem importing one of the Python modules
required to runyum. The error leading to this problem was:
No module namedyum
Please install apackage which provides this module, or
verify that themodule is installed correctly.
It‘s possiblethat the above module doesn‘t match the
current versionof Python, which is:
Python 2.7.8(default, Dec 3 2014, 10:51:34)
[GCC 4.1.220080704 (Red Hat 4.1.2-55)] on linux2
If you cannotsolve this problem yourself, please go to
the yum faq at:
http://wiki.linux.duke.edu/YumFaq
[[email protected]]# vim /usr/bin/yum
#!/usr/bin/python #修改此处为2.6的位置
[[email protected] ~]# vim/usr/bin/yum
#!/usr/bin/python2.6
[[email protected]~]# yum
Loaded plugins:fastestmirror
You need to givesome command
usage: yum [options]COMMAND
List of Commands:
check-update Check for available package updates
clean Remove cached data
deplist List a package‘s dependencies
downgrade downgrade a package
erase Remove a package or packages fromyour system
groupinfo Display details about a package group
groupinstall Install the packages in a group on yoursystem
grouplist List available package groups
groupremove Remove the packages in a group from yoursystem
help Display a helpful usage message
info Display details about a package orgroup of packages
install Install a package or packages on yoursystem
list List a package or groups of packages
localinstall Install a local RPM
yum 可以使用;python升级成功。