python2.6升级python2.7

来源:互联网 发布:赵泓霖的网络课100节 编辑:程序博客网 时间:2024/05/16 09:45
  • 1.获取python2.7
wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz
  • 2.解压
tar -xzvf Python-2.7.3.tgz
  • 3.创建python2.7文件夹并且安装python2.7
./configure --prefix=/usr/local/python27make && make install
  • 4.备份老python
mv /usr/bin/python /usr/bin/python_old
  • 5.为新python建立连接
ln -s /usr/local/python27/bin/python2.7 /usr/bin/python
  • 6.查看版本
python -V

这里写图片描述

  • 7.修改yum的配置(不然会报错)
There was a problem importing one of the Python modulesrequired to run yum. The error leading to this problem was:   No module named yumPlease install a package which provides this module, orverify that the module is installed correctly.It's possible that the above module doesn't match thecurrent version of Python, which is:2.7.3 (default, Oct 25 2017, 10:13:29) [GCC 4.4.7 20120313 (Red Hat 4.4.7-17)]If you cannot solve this problem yourself, please go to the yum faq at:  http://yum.baseurl.org/wiki/Faq

只需要修改/usr/bin/yum文件,将(yum还是用2.6版本):

#!/usr/bin/python修改为#!/usr/bin/python_old

保存退出就搞定

原创粉丝点击