“没有名为 yum 的模块"使用 Python 2.7 [英] "No module named yum" with Python 2.7

查看:80
本文介绍了“没有名为 yum 的模块"使用 Python 2.7的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的项目需要使用 Python 2.7.但是安装了Python之后,就不能使用yum这个模块了.我有这个错误:

I need to use Python 2.7 for my project. But after installing Python, I can't use the module yum. I have this error :

[root@nexus-chat2 .synapse]# 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.5 (default, Feb 19 2018, 14:55:04) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-18)]

If you cannot solve this problem yourself, please go to 
the yum faq at:
  http://yum.baseurl.org/wiki/Faq

你知道我该如何解决吗?我使用 CentOS 6

Do you know how can I fix that ? I use CentOS 6

推荐答案

yum 模块不是一个常用的 Python 模块.需要为您在系统上安装的任何版本的 Python 显式构建和安装它.在 CentOS 6 中,系统 Python 是 python 2.6(并且 yum 模块将默认可用).

The yum module is not a stock Python module. It would need to be built and installed explicitly for any version of Python you install on your system. With CentOS 6, the system Python is python 2.6 (and the yum module will be available by default).

如果您想让 yum 模块可用于您的 Python 2.7 安装,您需要针对您的 Python 2.7 安装构建 yum,这可能是一个非-琐碎的任务.

If you wanted to make the yum module available to your Python 2.7 install, you would need to build yum against your Python 2.7 install, which may be a non-trivial task.

最简单的解决方案是 (a) 仅使用 Python 2.6 或 (b) 升级到更新的发行版.

The simplest solutions are (a) just use Python 2.6 or (b) upgrade to a more recent distribution.

这篇关于“没有名为 yum 的模块"使用 Python 2.7的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆