1) Compile and install python2.7
[[email protected] ~]# python -vpython 2.6.6 View Python version information (previous yum was installed by yum) [[Email protected] src]# wget https://www.python.org/ftp/python/2.7.9/python-2.7.9.tar.xz[[email protected] src]# file Python-2.7.9.tar.xz Python-2.7.9.tar.xz: xz Compressed data[[email protected] src]# xz -d python-2.7.9.tar.xz [[email protected] src]# lsdebug kernels python-2.7.9.tar[[email protected] src]# tar -xf Python-2.7.9.tar [[email protected] src]# cd python-2.7.9[[email protected] python-2.7.9]# ./configure [[email protected] python-2.7.9]# make && make install[[email protected] python-2.7.9]# echo $?0[[email protected] python-2.7.9]# /usr/local/bin/python2.7 -vpython 2.7.9[[email protected] pYTHON-2.7.9]# MV /USR/BIN/PYTHON /USR/BIN/PYTHON2.6MV: Do you want to overwrite "/usr/bin/python2.6"? yes[[email protected] python-2.7.9]# ln -s /usr/local/bin/python2.7 /usr/ bin/python[[email protected] python-2.7.9]# python -vpython 2.7.9
2) Adjust the configuration of Yum
Because Yum uses the information that calls Python, avoids reinstalling Python, yum error, edit yum file: [[email protected] python-2.7.9]# sed - i ' [email protected]#!/usr/bin/[email protected]#!/usr/bin/[email protected] ' /usr/ bin/yum[[email protected] python-2.7.9]# cat /usr/bin/yum |head#!/usr/bin/ python2.6import systry: import yumexcept importerror: print >> sys.stderr, "" "There was a problem importing one of the python modulesrequired to run yum. the error leading to this problem was: %s[[email protected] Python-2.7.9]# pythonpython 2.7.9 (default, nov 16 2016, 19:53:47) [GCC 4.4.7 20120313 (red hat 4.4.7-16)] on linux2type "Help", "copyright", " Credits " or " License " for more information.>>> print "Hello,world" Hello,world to this, python2.7 's basic installation has also been completed.
This article is from the "Frozen vs watermelon" blog, so be sure to keep this source http://molewan.blog.51cto.com/287340/1873670
One of the Python starter series: CENTOS6 under python2.7 installation