Yum error caused by Python upgrade

Source: Internet
Author: User

Yum error caused by Python upgrade

One day, you need to install an rpm package on the Linux server. As a result, when you run the yum command, an error is reported in any case, as shown below:

[Root @ test 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
Current version of Python, which is:
2.7.10 (default, Sep 7 2015, 10:39:35)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)]
If you cannot solve this problem yourself, please go
The yum faq:
Http://yum.baseurl.org/wiki/Faq

The error message says:

It's possible that the above module doesn't match
Current version of Python, which is:
2.7.10 (default, Sep 7 2015, 10:39:35)

I suspect it is related to the upgraded Python, but I cannot help yum with the upgraded Python,

For more information, see:

[Root @ test bin] # strace yum
Execve ("/usr/bin/yum", ["yum"], [/* 30 vars */]) = 0
Brk (0) = 0x1849000
........
Stat ("/usr/bin", {st_mode = S_IFDIR | 0555, st_size = 40960,...}) = 0
Stat ("/usr/bin/yum", {st_mode = S_IFREG | 0755, st_size = 801,...}) = 0
Open ("/usr/bin/yum. so", O_RDONLY) =-1 ENOENT (No such file or directory)
Open ("/usr/bin/yummodule. so", O_RDONLY) =-1 ENOENT (No such file or directory)
Open ("/usr/bin/yum. py", O_RDONLY) =-1 ENOENT (No such file or directory)
Open ("/usr/bin/yum. pyc", O_RDONLY) =-1 ENOENT (No such file or directory)
Stat ("/usr/local/lib/python2.7/yum", 0x7fff5cca59c0) =-1 ENOENT (No such file or directory)
Open ("/usr/local/lib/python2.7/yum. so", O_RDONLY) =-1 ENOENT (No such file or directory)
Open ("/usr/local/lib/python2.7/yummodule. so", O_RDONLY) =-1 ENOENT (No such file or directory)
Open ("/usr/local/lib/python2.7/yum. py", O_RDONLY) =-1 ENOENT (No such file or directory)
Open ("/usr/local/lib/python2.7/yum. pyc", O_RDONLY) =-1 ENOENT (No such file or directory)
Stat ("/usr/local/lib/python2.7/plat-linux2/yum", 0x7fff5cca59c0) =-1 ENOENT (No such file or directory)
.....
Write (2, "There was a problem importing on"..., 527 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
Current version of Python, which is:
2.7.10 (default, Sep 7 2015, 10:39:35)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)]
If you cannot solve this problem yourself, please go
The yum faq:
Http://yum.baseurl.org/wiki/Faq

) = 527
Write (2, "\ n", 1
) = 1
Rt_sigaction (SIGINT, {SIG_DFL, [], SA_RESTORER, 0x343800f500}, {0x4e4a30, [], SA_RESTORER, 0x343800f500}, 8) = 0
Brk (0x1907000) = 0x1907000
Exit_group (1) =?
[Root @ test bin] #

Through the strace command, we found that the lower half of the log is errors caused by Python,

Then I remembered that Python 2.66 was used in the system, and then I upgraded it to 2.7.10.

Will it be caused by this problem? Then, I downloaded a Python 2.66 from other servers (in the same version), put it in the/usr/bin directory, and rename it python2.6.

Then execute the command to find the location of yum, and vi open the yum file and change the Python in the first line to python2.6.

Modify the scripts starting with other yum.

[Root @ test bin] # which yum
/Usr/bin/yum
[Root @ test bin] # vi yum
[Root @ test bin] # head-n 1 yum *
==> Yum <=
#! /Usr/bin/python2.6
==> Yum-builddep <=
#! /Usr/bin/python2.6-tt
==> Yum-config-manager <=
#! /Usr/bin/python2.6-tt
==> Yum-debug-dump <=
#! /Usr/bin/python2.6-tt
==> Yum-debug-restore <=
#! /Usr/bin/python2.6-tt
==> Yumdownloader <=
#! /Usr/bin/python2.6
==> Yum-groups-manager <=
#! /Usr/bin/python2.6-tt

Run the yum command again to solve the problem!

For more YUM tutorials, see the following:

RedHat 6.2 modify yum source in Linux use CentOS source for free

Configure the epel yum Source

Redhat local yum source configuration

Description of yum configuration file

Install yum in RedHat 6.1)

YUM installation and cleaning

Build yum local source on CentOS 6.4

This article permanently updates the link address:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.