Why yum fails on system with "No module named yum" error ?

Solution Verified - Updated -


  • Red Hat Enterprise Linux (RHEL)


  • Performing yum update results in the error "No module named yum"
  • While running "sosreport" fails with "No module named os"


  • Unset the PYTHONHOME variable:
    # unset PYTHONHOME

For permanent change remove entry from root's .bashrc or .bash_profile if present.

  • Reinstall python package by running following command:
      # rpm -Uvh --replacefiles --replacepkgs python-<version>.rpm

Root Cause

  • PYTHONHOME variable was set as environment variable on system.
  • Python libraries/files are modified which can be observed from output of rpm -Va command.
  • Third party python modules are installed on system which found in output of "ldd /usr/bin/python" command.
  • The package rpm-python* is not installed.

Diagnostic Steps

# sosreport 

'import site' failed; use -v for traceback 
Traceback (most recent call last): 
  File "/usr/sbin/sosreport", line 29, in ? 
    import os 
ImportError: No module named os 

# yum -d10 update
'import site' failed; use -v for traceback 
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.4.3 (#1, Jul 16 2009, 06:20:46) 
[GCC 4.1.2 20080704 (Red Hat 4.1.2-44)] 

If you cannot solve this problem yourself, please go to 
the yum faq at: 

Collect the following details from system

# rpm -qa --queryformat "%{NAME}-%{VERSION}-%{RELEASE}-%{ARCH}\n" | sort > /tmp/rpm-list
# ldd /usr/bin/python

Strace command output
# strace -fxvto /tmp/strace.out yum update 

# which python
# env > /tmp/env.out 
# rpm -qf `which yum`
# rpm -Va > /tmp/rpm_va

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.