- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的操作系统是 CentOS Linux release 7.4.1708
首先,我为 python 安装了 anaconda。然后我替换了/usr/bin/python 中的默认 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.
>>>
所以我不能再使用 yum。
$ 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
我尝试将第一行 vi/usr/bin/yum
修复到任何其他 python 路径。但它不起作用。
另外,我正在尝试像这样重新安装 python*.rpm:
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
并重新安装yum*.rpm
(我今天下载了很多*.rpm
...)但是,还是不行。有人帮我吗?谢谢!
最佳答案
我最近在 CentOS7 上用 Yum3.4.3,Python2.7.5 遇到了这个问题,
[root@centos64b build]# yum list There was a problem importingone of the Python modules required to run yum. The error leading tothis problem was:
No module named yum
Please install a package which provides this module, or verify thatthe module is installed correctly.
It's possible that the above module doesn't match the current versionof 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 faqat: http://yum.baseurl.org/wiki/Faq
虽然我在遇到这个问题之前没有更新Python。最后发现sys.path中没有设置python site-packages libpath,所以这里的修复是在/usr/bin/yum Python脚本中将site-package libpath追加到sys.path中。然后 yum 工作正常。
[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')
关于python - "No module named yum"centos7,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51855290/
我是一名优秀的程序员,十分优秀!