"No module named yum" centos7
I got this problem on CentOS7 with Yum3.4.3, Python2.7.5 recently,
[root@centos64b build]# yum list 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, Apr 11 2018, 07:36:10) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]
If you cannot solve this problem yourself, please go to the yum faq at: http://yum.baseurl.org/wiki/Faq
While I did not update Python before I met this problem. Finally it is found that python site-packages libpath was not set in sys.path, so the fix here is to append the site-package libpath to sys.path in /usr/bin/yum Python script. Then yum works fine.
[build@centos64b ~]$ more /usr/bin/yum
#!/usr/bin/python
import sys
sys.path.append('/usr/lib/python2.7/site-packages')
sys.path.append('/usr/lib64/python2.7/site-packages')
Yi Levin
Updated on July 17, 2022Comments
-
Yi Levin almost 2 years
my OS is CentOS Linux release 7.4.1708
First,I install anaconda for python.then I replace the default python in /usr/bin/python.
$ ll /usr/bin/python* lrwxrwxrwx. 1 root root 7 Aug 15 03:40 /usr/bin/python -> python2 lrwxrwxrwx. 1 root root 9 Aug 9 22:10 /usr/bin/python3 -> python3.6 lrwxrwxrwx. 1 root root 29 Aug 9 22:10 /usr/bin/python2.7 -> /root/anaconda2/bin/python2.7 lrwxrwxrwx. 1 root root 29 Aug 9 21:59 /usr/bin/python3.6 -> /root/anaconda3/bin/python3.6 lrwxrwxrwx. 1 root root 9 Aug 8 23:49 /usr/bin/python2 -> python2.7 Python 2.7.15 |Anaconda, Inc.| (default, May 1 2018, 23:32:55) [GCC 7.2.0] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>>
so I can't use yum any more.
$ 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.15 |Anaconda, Inc.| (default, May 1 2018, 23:32:55) [GCC 7.2.0] If you cannot solve this problem yourself, please go to the yum faq at: http://yum.baseurl.org/wiki/Faq
I'm try to fix
vi /usr/bin/yum
the first line to any other python path. but it doesn't work.also,I'm trying to reinstall python*.rpm like this:
rpm -ivh python-tools-2.7.5-68.el7.x86_64.rpm python-2.7.5-68.el7.x86_64.rpm python-libs-2.7.5-68.el7.x86_64.rpm tkinter-2.7.5-68.el7.x86_64.rpm
and reinstall
yum*.rpm
(I download a lot of*.rpm
today...) but, still not work. anyone give me a hand? thanks! -
Yi Levin almost 6 yearsbut I can't find the old python, all the /usr/bin/python* is I installed , the default pythonx.y was remove.
-
Bambam Deo almost 6 yearsWhichever version is present, try to link it using the ln command. & also to fix yum, you'll need to edit /etc/yum/yum.conf
-
Yi Levin almost 6 yearshow to link? please help me, my python2.6 is
/usr/local/bin/python
my python2.7 is `` /usr/bin/python`` but the default python is python2.6. and also, I don't know how to fix yum the content is here.vi /etc/yum/yum.conf [main] cachedir=/var/cache/yum/$basearch/$releasever keepcache=0 debuglevel=2 logfile=/var/log/yum.log exactarch=1 obsoletes=1 gpgcheck=1 plugins=1 installonly_limit=5 bugtracker_url=http://bugs.centos.org/set_project.php?project_id=23&ref=http://bugs.centos.org/bug_report_page.php?category=yum distroverpkg=centos-release
-
Bambam Deo almost 6 yearsCn you sare output of the following command
ls -l /usr/bin pyth*
andls -l /usr/local/bin pyth*
-
Bambam Deo almost 6 yearsMost probably, following two commands shhould fix your problem, ` rm /usr/bin/python; ln -s /usr/local/bin/python /usr/bin/python`
-
Val K over 3 yearsThanks! You made my day! Also I added these lines into
/usr/libexec/urlgrabber-ext-down