Tuesday, April 12, 2022

[SOLVED] "No module named yum" with Python 2.7

Issue

I need to use Python 2.7 for my project. But after installing Python, I can't use the module yum. I have this error :

[root@nexus-chat2 .synapse]# 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 the
current version of Python, which is:
2.7.5 (default, Feb 19 2018, 14:55:04) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-18)]

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

Do you know how can I fix that ? I use CentOS 6


Solution

The yum module is not a stock Python module. It would need to be built and installed explicitly for any version of Python you install on your system. With CentOS 6, the system Python is python 2.6 (and the yum module will be available by default).

If you wanted to make the yum module available to your Python 2.7 install, you would need to build yum against your Python 2.7 install, which may be a non-trivial task.

The simplest solutions are (a) just use Python 2.6 or (b) upgrade to a more recent distribution.



Answered By - larsks
Answer Checked By - Willingham (WPSolving Volunteer)