- 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/python27
make && 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 modules
required to run yum. The error leading to this problem was:
No module named yum
Please install a package which provides this module, or
verify that the module is installed correctly.
It's possible that the above module doesn't match the
current 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
保存退出就搞定