Yum Error – ImportError: No module named yummain
You may see an error like the below when attempting to see if a certain package is installed using the yum package manager. Yum is the default package manager on RedHat Linux and CentOS Linux. Using the “yum list *SOMETEXT*” command will list all packages that contain “sometext” or you could use “yum list sometext” which will list a package specifically called “sometext”. Below you can see an attempt to list the “git” package on a CentOS server however an error was returned.
Yum List Error Example:
[web@server ~]$ yum list *GIT* Traceback (most recent call last): File "/usr/bin/yum", line 28, in ? import yummain ImportError: No module named yummain
The problem is that the user you are attempting to verify the package for does not have access to yum. Make sure you are using the proper user which would typically be root. A successful attempt to verify git will look like the below.
Successful Yum List Attempt:
[root@server ~]# yum list git Loading "installonlyn" plugin Setting up repositories Reading repository metadata in from local files Installed Packages git.x86_64 126.96.36.199-1.el5.rf installed
Running the command “yum list git” should tell you the version of git installed and if there are any updates available. Below is the output of “yum –help” to give you an idea of how yum can be used.
Output of Yum Help:
[root@dev ~]# yum --help Loading "installonlyn" plugin usage: yum [options] < grouplist, localinstall, groupinfo, localupdate, resolvedep, erase, deplist, groupremove, makecache, upgrade, provides, shell, install, whatprovides, groupinstall, update, groupupdate, info, search, check-update, list, remove, clean, grouperase > options: -h, --help show this help message and exit -t, --tolerant be tolerant of errors -C run entirely from cache, don't update cache -c [config file] config file location -R [minutes] maximum command wait time -d [debug level] debugging output level -e [error level] error output level -y answer yes for all questions --version show Yum version and exit --installroot=[path] set install root --enablerepo=[repo] enable one or more repositories (wildcards allowed) --disablerepo=[repo] disable one or more repositories (wildcards allowed) -x [package], --exclude=[package] exclude package(s) by name or glob --obsoletes enable obsoletes processing during updates --noplugins disable Yum plugins
For the initial error just make sure that you are using yum with the proper user or provide the user you want to use yum the proper permissions.