Download the source tar package
:https://www.python.org/downloads/
I download the python-2.7.11.tgz here
# TAR-ZXVF Python-2.7.11.tgz
Go to the Unpacked folder
# CD Python-2.7.11
Build a folder in/usr/local before compiling python2 (as a Python installation path to avoid overwriting the old version)
# Mkdir/usr/local/python2
Start compiling the installation
#./configure--prefix=/usr/local/python2# make# make install
Move the previous version
# Mv/usr/bin/python/usr/bin/python_old
Link to build a new version of Python
Ln-s/usr/local/python2/bin/python/usr/bin/python
This time input
# Pythonpython 2.7.11 (default, Feb, 18:01:00) [GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on Linux2type "help", "Copyr Ight "," credits "or" license "for more information.>>>
Complete
As the new version of Python is affected by the use of Yum, the situation is as follows
# yum grouplistthere 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.11 (default, feb 19 2016, 18:01:00) [GCC 4.8.5 20150623 (red hat 4.8.5-4)]if you cannot Solve this problem yourself, please go to the yum faq at: http://yum.baseurl.org/wiki/faq
Python version does not match, we modify Yum as the old version of Python just
View the original Python location
# Whereis Pythonpython:/usr/bin/python2.7/usr/bin/python/usr/lib/python2.7/usr/lib64/python2.7/usr/include/ Python2.7/usr/share/man/man1/python.1.gz
# Vim/usr/bin/yum
Modify the first line#!/usr/bin/pythonFor#!/usr/bin/python2.7
OK. Complete
This article is from the "Home_tang" blog, make sure to keep this source http://yagetang.blog.51cto.com/1780698/1743501
Linux Source Installation python