Python yum---没有名为 yum 的模块

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18632016/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 11:16:19  来源:igfitidea点击:

yum---no module named yum

pythonyum

提问by cjmandlulu

when I use yum in the shell,the error message is no module named yum, so I edit the /usr/bin/yum change the first line to another version of python, but nothing changes,and when I user different python to import yum, it brings out different error enter image description here

当我在 shell 中使用 yum 时,错误信息是没有名为 yum 的模块,所以我编辑 /usr/bin/yum 将第一行更改为另一个版本的 python,但没有任何变化,当我使用不同的 python 导入 yum 时,它带来了不同的错误 在此处输入图片说明

enter image description here

在此处输入图片说明

and when i use yum ,the message is like this: enter image description herethe yum is ok before i use "rpm -e --nodeps pycurl" to remove pycurl...i need some help:(

当我使用 yum 时,消息是这样的: 在此处输入图片说明在我使用“rpm -e --nodeps pycurl”删除 pycurl 之前,yum 没问题……我需要一些帮助:(

回答by Alexander Kanevskiy

You created problem for yourself by removing pycurl with --nodeps flag. To get this error above resolved, please re-install pycurl package into your system manually.

您通过使用 --nodeps 标志删除 pycurl 为自己创造了问题。要解决上述错误,请手动将 pycurl 包重新安装到您的系统中。

回答by PytLab

Changing the first line of /usr/bin/yumto the default version of python may help.

将第一行更改/usr/bin/yum为 python 的默认版本可能会有所帮助。

eg.change #!/usr/bin/pythonto #!/usr/bin/python2.4

例如.更改#!/usr/bin/python#!/usr/bin/python2.4

回答by Sridhar Mamilla

download this rpm

python-2.4.3-46.el5_8.2.i386.rpm
python-devel-2.4.3-46.el5_8.2.i386.rpm
python-libs-2.4.3-46.el5_8.2.i386.rpm
python-tools-2.4.3-46.el5_8.2.i386.rpm
tix-8.4.0-11.fc6.i386.rpm
tix-devel-8.4.0-11.fc6.i386.rpm
tkinter-2.4.3-46.el5_8.2.i386.rpm
yum-3.2.22-39.el5.centos.noarch.rpm

http://mirror.centos.org/centos/5/os/i386/CentOS/

[root@localhost x]# ls
python-2.4.3-46.el5_8.2.i386.rpm tix-8.4.0-11.fc6.i386.rpm
python-devel-2.4.3-46.el5_8.2.i386.rpm tix-devel-8.4.0-11.fc6.i386.rpm
python-libs-2.4.3-46.el5_8.2.i386.rpm tkinter-2.4.3-46.el5_8.2.i386.rpm
python-tools-2.4.3-46.el5_8.2.i386.rpm yum-3.2.22-39.el5.centos.noarch.rpm

[root@localhost x]# rpm -Uvh --replacepkgs *.rpm
Preparing... ########################################### [100%]
1:tix ########################################### [ 13%]
2:tix-devel ########################################### [ 25%]
3:python ########################################### [ 38%]
4:tkinter ########################################### [ 50%]
5:python-devel ########################################### [ 63%]
6:python-libs ########################################### [ 75%]
7:python-tools ########################################### [ 88%]
8:yum ########################################### [100%]
[root@localhost x]# yum update

回答by Beben

when "no module named yum" happen, you should re-install the proper python & yum rpm package manually, for instance :

当“没有名为 yum 的模块”发生时,您应该手动重新安装正确的 python 和 yum rpm 包,例如:

rpm -i python*.rpm

rpm -i yum*.rpm

rpm -i python*.rpm

rpm -i yum*.rpm