Recently installed on the CentOS Python2.7, so there are several Python versions of the Linux system, resulting yum command error, prompted by: "No module named Yum", by modifying the yum command file, Replacing the correct path to Python solves the problem that Yum cannot use.
The Yum command specific error message is as follows:
[root@10-8-69-125 ~]# Yumthere is a problem importing one of the Python modulesrequired to run yum. The error leading to this problem Was:no module named Yumplease Installa package Whichprovides This module, orverify that The module is installed correctly. It's possible that's above module doesn ' t match thecurrent version of Python, whichis:2.7.3 (default, May 29 2017, 16:4 4:21) [GCC 4.4.7 20120313 (Red Hat 4.4.7-18)]if You cannot solve "This problem yourself, and go to the Yum FAQ at:http ://yum.baseurl.org/wiki/faq
Bash
Copy
This is because Yum is written in Python and if more than one Python version is installed in Linux, there will be an "No module named yum" Error, and the workaround is to replace the Python version path used by Yum.
Resolve "No module named yum" 1, find the current path to Python
Using the Whereis Python command lookup, you can see that there are currently two Python versions installed in the CentOS system, python2.6 and python2.7 respectively.
[root@10-8-69-125 ~]# whereis Pythonpython:/usr/bin/python/usr/bin/python2.6/usr/lib/python2.6/usr/lib64/ python2.6/usr/local/bin/python2.7/usr/local/bin/python/usr/local/bin/python2.7-config/usr/local/lib/python2.7/ Usr/include/python2.6/usr/share/man/man1/python.1.gz
Bash
Copy
2. Modify/usr/bin/yum File
You can solve the problem by opening the/usr/bin/yum file and replacing it with the correct path to Python. Amend the #!/usr/bin/python in the document to
#!/usr/bin/python2.6
Bash
Copy
Then save it.
The contents of the modified/usr/bin/yum file are shown below:
This yum can not be used to solve the problem, the use of Yum again, the normal use of:
[root@10-8-69-125 ~]# yum Loaded plugin: Fastestmirror You need to give a command Usage:yum [options]commandlist of Commands:check check Forproblems Inthe rpmdbcheck-update Check for package updates clean Delete cached data deplist list package dependencies distribution-synchronization Synchronize installed Packages to the latest available Versionsdowngrade downgrade a packageerase remove one or more packages from the system GroupInfo display group details Groupinstall Install a set of packages to the system Grouplist list the installable groups Groupremove remove a set of packages from the system help display usage information historydisplay, or use, the transaction historyinfo Display details about a package or group install install one or more packages to the system list lists one or a set of packages load-transaction load a saved transaction from Filenamemakecache Create a metadata cache provides find packages that provide specified content reinstall overwrite install a package repolist show configured warehouses RESOLVEDEP determine which package provides the specified dependency search in package details searching for the specified string shell Running one or more packages in the interactive Yum Shell update update system Upgrade update package at the same time consider the package replace relationship version Display a version forthe machine and/or available.
Bash
Copy