【发布时间】:2018-08-15 08:24:25
【问题描述】:
我的操作系统是 CentOS Linux 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...)
但是,仍然无法正常工作。
有人帮我一把吗?谢谢!
【问题讨论】:
-
这里是相关问题的解决方案enter link description here
-
这里是解决方案:"No module named yum” centos7
-
尝试使用
--force选项重新安装Python包。 -
@Zalatik 如何使用 --force 重新安装 Python 包?
-
@YiLevin
rpm -ivh --force python-2.7.5-68.el7.x86_64.rpm