[root@zyl ~]# python -V
Python 2.6.6
[root@zylpython]#wgethttp://python.org/ftp/python/2.7.8/Python-2.7.8.tgz
root@zyl python]#tar xf Python-2.7.8.tgz
[root@zylpython]# cd /Python-2.7.8
[root@zylPython-2.7.8]# ./configure --prefix=/usr/local/python27
[root@zylPython-2.7.8]#make
[root@zylPython-2.7.8]# make install
最新2.7.8版本的python已经安装到了系统中,但是还没有完成
再次查看python版本,发现依然是2.6.6版本
[root@zyl ~]#python -V
Python 2.6.6
1.把原来的python重命名成python_old,注意不要删除它
[root@zylPython-2.7.8]# mv /usr/bin/python /usr/bin/python_old
2.建立新的python的软连接
[root@zylPython-2.7.8]# ln -s /usr/local/python27/bin/python /usr/bin/
3. 再查看一下版本,发现ok
[root@zyl ~]#python -V
Python 2.7.8
至此我们已经可以正常使用python2.7.X
但是我们还有最后一个问题要解决:但是因为yum是使用的python2.4的版本,所以,还需要修改一下(前面我们重命名的python_old现在派上用场)
[root@zyl ~]# 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
[root@zylPython-2.7.8]# vim /usr/bin/yum
#!/usr/bin/python #修改此处为2.6的位置
[root@zyl ~]# vim/usr/bin/yum
#!/usr/bin/python2.6
[root@zyl~]# 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升级成功。
本文出自 “zhangyiling” 博客,转载请与作者联系!
原文地址:http://813415154.blog.51cto.com/10900500/1813929