简体   繁体   中英

Yum “cannot import name Errors” - Red Hat 4.4 with Python 2.6 / 2.7

Any yum command I try to run, returns the following:

    There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:

   cannot import name Errors

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.6.6 (r266:84292, Aug 18 2016, 15:13:37)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-17)]

If you cannot solve this problem yourself, please go to
the yum faq at:
  http://yum.baseurl.org/wiki/Faq

This is what I've done and what I know:

OS is Red hat 4.4.7018

I believe Python was 2.6 and was updated to 2.7 some time ago (I suspect this might have broken yum)

python -V returns 2.7.13

# ls -lrt /usr/bin/python*
-rwxr-xr-x. 1 root root 4864 Aug 18  2016 /usr/bin/python2.6
lrwxrwxrwx. 1 root root    6 Mar  8 13:16 /usr/bin/python2 -> python
lrwxrwxrwx. 1 root root   24 Mar  8 13:32 /usr/bin/python -> /usr/local/bin/python2.7

# ls /usr/bin/python*
/usr/bin/python  /usr/bin/python2  /usr/bin/python2.6

# ls /usr/local/bin/python*
/usr/local/bin/python2.7  /usr/local/bin/python2.7-config

I've tried running import yum on all phytons and only the 2.6 does not give me an error, so I tried changing the links back to 2.6 (Validated with python -V to check it goes back to version 2.6.6), and yum still returns the "cannot import name Errors" error.

Also, the PATH variable:

# echo $PATH

    /usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/local/git/bin:/root/bin

The python configured on /usr/bin/yum is #!/usr/bin/python2.6 , I've tried changing it to /python , and even /phyton2 and I still get the error.

the yum command in old version of red hat(6 and older) work with python 2.6

are you test yum command with unlink /usr/bin/python and add new link from /bin/python to /usr/bin/python2.6 ?

if the result is like same error try to recompile python6 OR update your yum pkgs on server

I'm not a Linux expert, but this looks like Red Hat 6 (which had python 2.6 as default) [1]. The 4.4 is the version of GCC. When you've got python 2.6 back in place and still need Python 2.7, then install the latter via the Software Collections channel - this will install 2.7 alongside the 2.6 version and not replace it to mess up the OS.

[1] How to confirm RedHat Enterprise Linux version? [2] https://developers.redhat.com/products/softwarecollections/hello-world/#fndtn-python

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM