0

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.

Resalith
  • 11
  • 3

2 Answers2

0

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

Elham_Jahani
  • 369
  • 2
  • 8
0

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

Mike Guerette
  • 533
  • 3
  • 6
  • Ah yes, it is Release 6.7, thanks! I've changed the Symlink back to 2.6 and I still got the error so I'm thinking something broke on 2.6 upon the 2.7 install and I'll have to fix that before re-installing 2.7? Do you think I should still go ahead and reinstall the 2.7? I dunno – Resalith Mar 12 '18 at 14:25
  • I suggest reverting to the original OS state as that will probably be less painful. :/ – Mike Guerette Mar 16 '18 at 20:06
  • It's a server that has some important production configuration, so it will be very painful if we decided to revert it to its original state :/ But it looks like we're headed that way :/ – Resalith Mar 19 '18 at 14:32