1. View version
#python-V
Python 2.6.6
2, pre-installation, installation of the relevant library
#yum install gcc gcc-c++ autoconf automake
#yum Install OpenSSL Openssl-devel
3. Download and install
#wget https://www.python.org/ftp/python/2.7.11/Python-2.7.11.tgz
#tar-xvzf python-2.7.11.tgz
#cd Python-2.7.11
#./configure--prefix=/usr/local/python2.7
#make
#make Install
4. Modify the Python link to point to
#mv/usr/bin/python/usr/bin/python2.6.6.old
#ln-S/usr/local/python2.7/bin/python/usr/bin/python
(L is L, do not write in)
View version
# python-v
Python 2.7.11
5. Modify the Python version used by Yum
Although Python is now installed, there are problems with the Yum command--yum not working properly:
# Yum List
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
Install a package which provides this module, or
Verify the module is installed correctly.
It ' s possible that the above module doesn ' t match the
Current version of Python, which is:
2.7.11 (default, 17 2016, 23:54:43)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-17)]
If You cannot solve this problem yourself and go to
The Yum FAQ at:
Http://yum.baseurl.org/wiki/Faq
This is because the Python version that Yum uses by default is 2.6.6, and the current version of Python is 2.7.11, so the problem is that it just needs to be the default Python configuration version of Yum:
#vi/usr/bin/yum
Change the #!/usr/bin/python of the file header to
#!/usr/bin/python2.6
6. Modify Environment variables
$vim ~/.bash_profile
Modified to:
Python_home=/usr/local/python2.7
PATH=$PATH:$HOME/bin:$PYTHON _home/bin
$source. Bash_profile
Contos replacing the Python version