python - 没有名为 yum 的模块
问题描述
我用 Python 2.7 尝试了解决方案@yum---没有名为 yum 的模块和“没有名为 yum 的模块”,但没有帮助,听起来 yum 模块不是普通的 Python 模块,需要针对你的 Python 2.7 构建 yum安装,任何人都可以提供有关如何执行此操作的指导吗?
机器详情:
[usernames@machine]$ cat /etc/*elease
LSB_VERSION=base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Oracle Linux Server release 6.6
Red Hat Enterprise Linux Server release 6.6 (Santiago)
Oracle Linux Server release 6.6
错误:-
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.12 (default, Aug 11 2016, 12:02:22)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-11)]
If you cannot solve this problem yourself, please go to
the yum faq at:
http://yum.baseurl.org/wiki/Faq
解决方案
看起来被破坏的是系统Python in /usr/bin
,它知道在哪里可以找到 RHEL 安装的 Python 模块和共享对象。所以你需要重新安装 RHEL python rpms,而不仅仅是 yum。
RHEL/usr/bin/python
用于它的许多实用程序。 yum
是一个 Python(包装器)脚本。
看起来您使用的是 RHEL 6。所以 /usr/bin/python 必须是 2.6。这就是 RHEL 6 附带的。(对于 RHEL 7,它需要是 2.7.5)
因此,要解决问题,您需要从 RHEL rpms 重新安装系统 Python。为了使系统正常工作,/usr/bin/python 不能是 Python 的任意版本。
yum rpm 只会将 yum 文件重新安装到原始路径,但您需要从正确目录加载模块的 RHEL /usr/bin/python。rpm 不会安装 Python 意义上的模块。此外,还有许多其他模块具有共享库依赖项,例如 DBus 接口。
因此,为您的发行版获取 RHEL python-* rpms。您需要下载它们,或使用 ISO/DVD。rpm 本身不知道如何通过网络访问软件仓库,这是 yum 的工作,因此您必须手动完成。
或者,如果您有另一个系统运行相同版本的 RHEL,您可以复制文件。您可以使用rpm -Va
获取属于已修改的 rpm 的所有文件的列表。在正常操作期间,有许多文件会被修改。
(故事的寓意,不要覆盖/usr/bin/python,/usr/bin/python2。RHEL(和其他平台,Fedora等)依赖于系统python才能正常工作。)
推荐阅读
- r - expss 包中的显着性测试行
- python - shareplum 仅从 SharePoint 列表返回 7 列
- c++ - C++ 从按顺序执行的其他 constexpr lambda 创建 lambda 不能是 constexpr
- firebase - 如何摆脱这个错误?错误:没有创建 Firebase 应用“[DEFAULT]” - 调用 firebase.initializeApp()
- laravel - laravel 将数据动态卡到 1 模态
- java - activemq - javax.jms.IllegalStateException:AMQ219019:会话已关闭
- javascript - Sequelize Many to Many - 更新关联表
- javascript - 创建不带参数的 JavaScript 函数并使用点传递数据
- javascript - if 语句在单击时提示一个弹出框
- django - Hostgator VPS 中的 Django 部署 - 同一服务器上的 PHP 和 Python - easyapache24 和 mod-wsgi