Python2.7 installation tutorial
[root@~/software]# yum install bzip*[root@~/software]# wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz[root@~/software]# tar zxvf Python-2.7.3.tgz[root@~/software]# cd Python-2.7.3[root@~/software/Python-2.7.3]# ./configure[root@~/software/Python-2.7.3]# make && make install[root@~/software]# cd /usr/local/bin/[root@/usr/local/bin]# ls -al python*lrwxrwxrwx 1 root root 7 Nov 16 18:24 python -> python2lrwxrwxrwx 1 root root 9 Nov 16 18:24 python2 -> python2.7-rwxr-xr-x 1 root root 6162217 Nov 16 18:23 python2.7-rwxr-xr-x 1 root root 1624 Nov 16 18:24 python2.7-configlrwxrwxrwx 1 root root 16 Nov 16 18:24 python2-config -> python2.7-configlrwxrwxrwx 1 root root 14 Nov 16 18:24 python-config -> python2-config[root@/usr/local/bin]# /usr/local/bin/python -VPython 2.7.3
The installation is complete. However, because some software, such as node. js, depends on python2.7, You need to modify the system path. The python command points to version 2.7.3:
[root@/usr/local/bin]# cp /usr/bin/python /usr/bin/python.bak.2014.11.16[root@/usr/local/bin]# rm /usr/bin/python[root@/usr/local/bin]# ln -s /usr/local/bin/python2.7 /usr/bin/python
In this case, if a yum problem occurs,There was a problem importing one of the Python modules":
[root@~/software/Python-2.7.3]# yum search bzipThere was a problem importing one of the Python modulesrequired to run yum. The error leading to this problem was: No module named yum Please 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, Nov 16 2014, 18:22:57) [GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] If you cannot solve this problem yourself, please go to the yum faq at: http://yum.baseurl.org/wiki/Faq
This is because yum depends on older python versions and can be fixed as follows:
[root@~/software/Python-2.7.3]# vim /usr/bin/yum
Modify the first line of command line and point python to the specified version:
1 #!/usr/bin/python2.6 2 import sys 3 try: 4 import yum