The default installation package python linux version is 2.6.6, yum default program is dependent on the version of python packages, but some other programs such as nodejs, have to the 2.7 version, it is necessary to consider the compatibility issues after upgrading with the yum. Two-step, first upgrade python, then compatible yum:
Download python 2.7 version:
[root@centos ~]# cd /usr/local/src [root@centos src]# wget https://www.python.org/ftp/python/2.7.10/Python-2.7.10.tgz --2019-11-01 17:28:55-- https://www.python.org/ftp/python/2.7.10/Python-2.7.10.tgz Resolving www.python.org... 151.101.108.223, 2a04:4e42:a::223 Connecting to www.python.org|151.101.108.223|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 16768806 (16M) [application/octet-stream] Saving to: “Python-2.7.10.tgz” 4% [====> ] 670,943 6.86K/s eta 39m 50s 10% [============> ] 1,791,740 19.2K/s eta 28m 3s 34% [===========================================> ] 5,849,199 42.7K/s eta 9m 22s 66% [===================================================================================> ] 11,109,885 33.2K/s eta 3m 25s 91% [===================================================================================================================> ] 15,381,928 43.1K/s eta 45s 100%[==============================================================================================================================>] 16,768,806 53.8K/s in 8m 54s 2019-11-01 17:37:50 (30.7 KB/s) - “Python-2.7.10.tgz” saved [16768806/16768806]
Unpack, compile:
[root@centos src]# tar -zxvf Python-2.7.10.tgz [root@centos src]# cd Python-2.7.10 [root@entos Python-2.7.10]# ./configure --enable-shared --enable-loadable-sqlite-extensions \ > --prefix=/usr/local/python27 \ > --with-zlib \ > --with-ssl configure: WARNING: unrecognized options: --enable-loadable-sqlite-extensions, --with-zlib, --with-ssl checking build system type... i686-pc-linux-gnu checking host system type... i686-pc-linux-gnu checking for --enable-universalsdk... no checking for --with-universal-archs... 32-bit checking MACHDEP... linux2 checking EXTRAPLATDIR... checking for --without-gcc... no checking for gcc... no checking for cc... no checking for cl.exe... no configure: error: in `/usr/local/src/Python-2.7.10': configure: error: no acceptable C compiler found in $PATH See `config.log' for more details
Well, the compilation fails, suggesting that there is no C compiler installed gcc:
[root@centos Python-2.7.10]# yum install gcc Loaded plugins: fastestmirror, security Setting up Install Process Loading mirror speeds from cached hostfile warm | 5.3 kB 00 : 00 extras | 3.3 kB 00 : 00 os | 3.7 kB 00 : 00 updates | 3.4 kB 00:00 Resolving Dependencies --> Running transaction check ---> Package gcc.i686 0:4.4.7-23.el6 will be installed --> Processing Dependency: libgomp = 4.4.7-23.el6 for package: gcc-4.4.7-23.el6.i686 --> Processing Dependency: cpp = 4.4.7-23.el6 for package: gcc-4.4.7-23.el6.i686 --> Processing Dependency: libgcc >= 4.4.7-23.el6 for package: gcc-4.4.7-23.el6.i686 --> Processing Dependency: glibc-devel >= 2.2.90-12 for package: gcc-4.4.7-23.el6.i686 --> Processing Dependency: cloog-ppl >= 0.15 for package: gcc-4.4.7-23.el6.i686 --> Processing Dependency: libgomp.so.1 for package: gcc-4.4.7-23.el6.i686 --> Running transaction check ---> Package cloog-ppl.i686 0:0.15.7-1.2.el6 will be installed --> Processing Dependency: libppl_c.so.2 for package: cloog-ppl-0.15.7-1.2.el6.i686 --> Processing Dependency: libppl.so.7 for package: cloog-ppl-0.15.7-1.2.el6.i686 ---> Package cpp.i686 0:4.4.7-23.el6 will be installed --> Processing Dependency: libmpfr.so.1 for package: cpp-4.4.7-23.el6.i686 ---> Package glibc-devel.i686 0:2.12-1.212.el6_10.3 will be installed --> Processing Dependency: glibc-headers = 2.12-1.212.el6_10.3 for package: glibc-devel-2.12-1.212.el6_10.3.i686 --> Processing Dependency: glibc = 2.12-1.212.el6_10.3 for package: glibc-devel-2.12-1.212.el6_10.3.i686 --> Processing Dependency: glibc-headers for package: glibc-devel-2.12-1.212.el6_10.3.i686 ---> Package libgcc.i686 0:4.4.7-18.el6 will be updated ---> Package libgcc.i686 0:4.4.7-23.el6 will be an update ---> Package libgomp.i686 0:4.4.7-23.el6 will be installed --> Running transaction check ---> Package glibc.i686 0:2.12-1.209.el6 will be updated --> Processing Dependency: glibc = 2.12-1.209.el6 for package: glibc-common-2.12-1.209.el6.i686 ---> Package glibc.i686 0:2.12-1.212.el6_10.3 will be an update ---> Package glibc-headers.i686 0:2.12-1.212.el6_10.3 will be installed --> Processing Dependency: kernel-headers >= 2.2.1 for package: glibc-headers-2.12-1.212.el6_10.3.i686 --> Processing Dependency: kernel-headers for package: glibc-headers-2.12-1.212.el6_10.3.i686 ---> Package mpfr.i686 0:2.4.1-6.el6 will be installed ---> Package ppl.i686 0:0.10.2-11.el6 will be installed --> Running transaction check ---> Package glibc-common.i686 0:2.12-1.209.el6 will be updated ---> Package glibc-common.i686 0:2.12-1.212.el6_10.3 will be an update ---> Package kernel-headers.i686 0:2.6.32-754.23.1.el6 will be installed --> Finished Dependency Resolution Dependencies Resolved ======================================================================================================================================================================== Package Arch Version Repository Size ======================================================================================================================================================================== Installing: gcc i686 4.4.7-23.el6 os 8.2 M Installing for dependencies: cloog-ppl i686 0.15.7-1.2.el6 os 93 k cpp i686 4.4.7-23.el6 os 3.4 M glibc-devel i686 2.12-1.212.el6_10.3 updates 991 k glibc-headers i686 2.12-1.212.el6_10.3 updates 628 k kernel-headers i686 2.6.32-754.23.1.el6 updates 4.6 M libgomp i686 4.4.7-23.el6 os 137 k mpfr i686 2.4.1-6.el6 os 153 k ppl i686 0.10.2-11.el6 os 1.3 M Updating for dependencies: glibc i686 2.12-1.212.el6_10.3 updates 4.4 M glibc-common i686 2.12-1.212.el6_10.3 updates 14 M libgcc i686 4.4 . 7 - 23 .el6 os 115 k Transaction Summary ======================================================================================================================================================================== Install 9 Package(s) Upgrade 3 Package(s) Total download size: 38 M Is this ok [y/N]: y Downloading Packages: (1/12): cloog-ppl-0.15.7-1.2.el6.i686.rpm | 93 kB 00:00 (2/12): cpp-4.4.7-23.el6.i686.rpm | 3.4 MB 00:00 (3/12): gcc-4.4.7-23.el6.i686.rpm | 8.2 MB 00:00 (4/12): glibc-2.12-1.212.el6_10.3.i686.rpm | 4.4 MB 00:00 (5/12): glibc-common-2.12-1.212.el6_10.3.i686.rpm | 14 MB 00:00 (6/12): glibc-devel-2.12-1.212.el6_10.3.i686.rpm | 991 kB 00:00 (7/12): glibc-headers-2.12-1.212.el6_10.3.i686.rpm | 628 kB 00:00 (8/12): kernel-headers-2.6.32-754.23.1.el6.i686.rpm | 4.6 MB 00:00 (9/12): libgcc-4.4.7-23.el6.i686.rpm | 115 kB 00:00 (10/12): libgomp-4.4.7-23.el6.i686.rpm | 137 kB 00:00 (11/12): mpfr-2.4.1-6.el6.i686.rpm | 153 kB 00:00 (12/12): ppl-0.10.2-11.el6.i686.rpm | 1.3 MB 00:00 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Total 43 MB/s | 38 MB 00:00 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : kernel-headers-2.6.32-754.23.1.el6.i686 1/15 Updating : libgcc-4.4.7-23.el6.i686 2/15 Updating : glibc-common-2.12-1.212.el6_10.3.i686 3/15 Updating : glibc-2.12-1.212.el6_10.3.i686 4/15 Installing : glibc-headers-2.12-1.212.el6_10.3.i686 5/15 Installing : glibc-devel-2.12-1.212.el6_10.3.i686 6/15 Installing : libgomp-4.4.7-23.el6.i686 7/15 Installing : mpfr-2.4.1-6.el6.i686 8/15 Installing : cpp-4.4.7-23.el6.i686 9/15 Installing : ppl-0.10.2-11.el6.i686 10/15 Installing : cloog-ppl-0.15.7-1.2.el6.i686 11/15 Installing : gcc-4.4.7-23.el6.i686 12/15 Cleanup : glibc-common-2.12-1.209.el6.i686 13/15 Cleanup : glibc-2.12-1.209.el6.i686 14/15 Cleanup : libgcc-4.4.7-18.el6.i686 15/15 Verifying : kernel-headers-2.6.32-754.23.1.el6.i686 1/15 Verifying : libgcc-4.4.7-23.el6.i686 2/15 Verifying : cpp-4.4.7-23.el6.i686 3/15 Verifying : libgomp-4.4.7-23.el6.i686 4/15 Verifying : glibc-devel-2.12-1.212.el6_10.3.i686 5/15 Verifying : glibc-2.12-1.212.el6_10.3.i686 6/15 Verifying : mpfr-2.4.1-6.el6.i686 7/15 Verifying : glibc-headers-2.12-1.212.el6_10.3.i686 8/15 Verifying : ppl-0.10.2-11.el6.i686 9/15 Verifying : glibc-common-2.12-1.212.el6_10.3.i686 10/15 Verifying : gcc-4.4.7-23.el6.i686 11/15 Verifying : cloog-ppl-0.15.7-1.2.el6.i686 12/15 Verifying : glibc-common-2.12-1.209.el6.i686 13/15 Verifying : libgcc-4.4.7-18.el6.i686 14/15 Verifying : glibc-2.12-1.209.el6.i686 15/15 Installed: gcc.i686 0:4.4.7-23.el6 Dependency Installed: cloog-ppl.i686 0:0.15.7-1.2.el6 cpp.i686 0:4.4.7-23.el6 glibc-devel.i686 0:2.12-1.212.el6_10.3 glibc-headers.i686 0:2.12-1.212.el6_10.3 kernel-headers.i686 0:2.6.32-754.23.1.el6 libgomp.i686 0:4.4.7-23.el6 mpfr.i686 0:2.4.1-6.el6 ppl.i686 0:0.10.2-11.el6 Dependency Updated: glibc.i686 0:2.12-1.212.el6_10.3 glibc-common.i686 0:2.12-1.212.el6_10.3 libgcc.i686 0:4.4.7-23.el6 Complete!
Re-compile, and execute the installation:
[root@centos Python-2.7.10]# make && make install
Upgrade python, through soft link, pointing to the python 2.6.6 instead of 2.7.0
[root@centos bin]# ls python* -l -rwxr-xr-x 2 root root 6100 Aug 18 2016 python lrwxrwxrwx. 1 root root 6 Dec 13 2017 python2 -> python -rwxr-xr-x 2 root root 6100 Aug 18 2016 python2.6 [root@centos bin]# unlink python [root@centos bin]# unlink python2 [root@centos bin]# ls python* -l -rwxr-xr-x 1 root root 6100 Aug 18 2016 python2.6 [root@centos bin]# cp /usr/local/python27/bin/python2.7 /usr/bin/python2.7 [root@centos bin]# ls python* -l -rwxr-xr-x 1 root root 6100 Aug 18 2016 python2.6 -rwxr-xr-x 1 root root 7776 Nov 2 00:15 python2.7 [root@centos bin]# ln -s /usr/bin/python2.7 python [root@centos bin]# ln -s python python2 [root @ centos bin] # ls python * - l lrwxrwxrwx 1 root root 18 Nov 2 00:16 python -> /usr/bin/python2.7 lrwxrwxrwx 1 root root 6 Nov 2 00:16 python2 -> python -rwxr-xr-x 1 root root 6100 Aug 18 2016 python2.6 -rwxr-xr-x 1 root root 7776 Nov 2 00:15 python2.7 [root@centos bin]# python -V python: error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory
See a problem has cropped version, you can not find a library file, edit the configuration files in /etc/ld.so.conf, specify what library path:
Once you have saved it to take effect, the now ok:
[root@centos bin]# ldconfig
[root@centos bin]# python -V
Python 2.7.10
Now engaged in the second question: is compatible yum, yum will be prompted to import python implementation of packet error:
[root@centos bin]# 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.10 (default, Nov 1 2019, 17:58:54) [GCC 4.4.7 20120313 (Red Hat 4.4.7-23)] If you cannot solve this problem yourself, please go to the yum faq at: http://yum.baseurl.org/wiki/Faq
Through vi editing / usr / bin / yum, the first line to the last plus 2.6
try again:
[root@centos bin]# yum Loaded plugins: fastestmirror, security You need to give some command Usage: yum [options] COMMAND List of Commands: check Check for problems in the rpmdb check-update Check for available package updates clean Remove cached data
Kick call it a day.