python升级导致yum命令无法使用的解决办法

简介:

1、报错信息如下:

1
2
3
4
5
6
7
8
9
10
11
12
[root@sa ~] # yum install prce -y
There was a problem importing one of the Python modules required to run yum. 
The error leading to this problem was:
    libxml2.so.2: cannot  open  shared object  file : No such  file  or directory
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.6.6 (r266:84292, Oct 12 2012, 14:23:48) 
[GCC 4.4.6 20120305 (Red Hat 4.4.6-4)]
If you cannot solve this problem yourself, please go to the yum faq at:
   http: //yum .baseurl.org /wiki/Faq


1
2
3
4
5
6
7
8
9
10
11
[root@sa yum.repos.d] # yum repolist
There was a problem importing one of the Python modules required to run yum. 
The error leading to this problem was:
    libxml2.so.2: cannot  open  shared object  file : No such  file  or directory
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.6.6 (r266:84292, Oct 12 2012, 14:23:48) 
[GCC 4.4.6 20120305 (Red Hat 4.4.6-4)]
If you cannot solve this problem yourself, please go to the yum faq at:  
http: //yum .baseurl.org /wiki/Faq

------------------------------------------------------------------------------------------------------------------------

错误原因:错误信息描述为 yum 所依赖的python 不相符,请安装相对应的python即可


2、查看yum版本

1
2
3
[root@develop  local ] # rpm -qa |grep yum
yum-3.2.8-9.el5.centos.1
yum-metadata-parser-1.1.2-2.el5



3、查看python版本

1
2
3
4
[root@develop  local ] # whereis python  
python:  /usr/bin/python2 .4  /usr/bin/python  /usr/lib/python2 .4 
/usr/local/bin/python2 .6  /usr/local/bin/python2 .6-config  /usr/local/bin/python 
/usr/local/lib/python2 .6  /usr/share/man/man1/python .1.gz


果然装了两个版本python


4、执行python,查看到使用2.6.1的版本

[plain]view plaincopyprint?

[root@develop local]# python  

Python 2.6.1 (r261:67515, Aug 7 2010, 11:36:17)  

[GCC 4.1.2 20080704 (Red Hat 4.1.2-44)] on linux2  

Type "help", "copyright", "credits" or "license" for more information.  

>>>  


5、猜测yum调用了高版本的python。


6、解决方法:

查找yum和 yum-updatest文件,并编辑此py文件

1
2
3
4
[root@develop  local ] # which yum  
/usr/bin/yum  
[root@develop  local ] # vi /usr/bin/yum  
[root@develop  local ] # vi /usr/bin/yum-updatest


#!/usr/bin/python

改为:

#!/usr/bin/python2.4


然后保存OK.


如果不修改/usr/bin/yum ,则yum无法使用

如果不修改/usr/bin/yum-updatest  会出现如下错误

 File "/usr/sbin/yum-updatesd", line 35, in

    import dbus

ImportError: No module named dbus


当然,修改完后记着

1
2
3
[root@localhost google_appengine] # /sbin/service yum-updatesd restart  
Stopping yum-updatesd:                                     [FAILED]  
Starting yum-updatesd:                                     [ OK   ]


补充:yum基于python写的。


本文转自 Mr_sheng 51CTO博客,原文链接:http://blog.51cto.com/sf1314/2062329


相关文章
|
2月前
|
安全 Ubuntu 网络安全
宝塔面板升级python3
Python 是一种广泛使用的高级编程语言,因其简洁的语法和丰富的库而受到开发者的喜爱。在许多Web应用程序和后端开发环境中,Python已成为重要工具。使用宝塔面板时,保持Python更新至关重要。本文介绍如何在服务器上安全升级Python:从环境准备、检查当前版本、安装工具包、下载并编译新版本、配置环境变量到测试新版本,确保升级顺利进行。建议定期更新以利用新特性和性能改进,并备份数据以防万一。
120 6
|
8月前
|
存储 安全 数据安全/隐私保护
安全升级!Python AES加密实战,为你的代码加上一层神秘保护罩
【9月更文挑战第12天】在软件开发中,数据安全至关重要。本文将深入探讨如何使用Python中的AES加密技术保护代码免受非法访问和篡改。AES(高级加密标准)因其高效性和灵活性,已成为全球最广泛使用的对称加密算法之一。通过实战演练,我们将展示如何利用pycryptodome库实现AES加密,包括生成密钥、初始化向量(IV)、加密和解密文本数据等步骤。此外,还将介绍密钥管理和IV随机性等安全注意事项。通过本文的学习,你将掌握使用AES加密保护敏感数据的方法,为代码增添坚实的安全屏障。
255 8
|
8月前
|
JSON 安全 数据库
Python安全性大升级:OAuth与JWT,让你的应用穿上防弹衣🛡️
【9月更文挑战第6天】在数字世界中,每个应用都面临着安全威胁。作为Python开发者,构建强大的系统至关重要。OAuth和JWT为我们提供了坚实的安全保障。OAuth作为一种授权机制,让用户无需向第三方应用暴露敏感信息;JWT则通过自包含的信息传输,增强了安全性并提高了系统性能。利用Python生态中的这些工具,我们可以更好地保护用户数据,守护他们的信任与期待。下面是一个使用PyJWT生成和验证JWT的示例代码:(示例代码同上)通过这些技术,我们的应用能够更加稳健地在数字海洋中航行。
76 3
|
8月前
|
数据采集 Linux 网络安全
python 爬虫遇到的aiohttp证书错误解决办法
python 爬虫遇到的aiohttp证书错误解决办法
354 0
|
8月前
|
Python
python pip升级3-3
python pip升级3-3
|
9月前
|
Linux Python
Linux 升级安装 Python 3
Linux 升级安装 Python 3
124 2
|
9月前
|
JavaScript Java 开发者
Python: 从 2.7 升级到 3,我比 vue 慢了一点点
Python: 从 2.7 升级到 3,我比 vue 慢了一点点
|
9月前
|
API 开发工具 Python
【Azure Developer】使用 Azure Python SDK时,遇见 The resource principal named https://management.azure.com was not found in the tenant China Azure问题的解决办法
【Azure Developer】使用 Azure Python SDK时,遇见 The resource principal named https://management.azure.com was not found in the tenant China Azure问题的解决办法
|
9月前
|
Python
python 升级后 yum 无法使用 File "/usr/bin/yum", line 30 except KeyboardInterrupt, e: `/usr/libexec/urlgrabber-ext-down`
python 升级后 yum 无法使用 File "/usr/bin/yum", line 30 except KeyboardInterrupt, e: `/usr/libexec/urlgrabber-ext-down`
130 0
|
3月前
|
缓存 Ubuntu Linux
Linux中yum、rpm、apt-get、wget的区别,yum、rpm、apt-get常用命令,CentOS、Ubuntu中安装wget
通过本文,我们详细了解了 `yum`、`rpm`、`apt-get`和 `wget`的区别、常用命令以及在CentOS和Ubuntu中安装 `wget`的方法。`yum`和 `apt-get`是高层次的包管理器,分别用于RPM系和Debian系发行版,能够自动解决依赖问题;而 `rpm`是低层次的包管理工具,适合处理单个包;`wget`则是一个功能强大的下载工具,适用于各种下载任务。在实际使用中,根据系统类型和任务需求选择合适的工具,可以大大提高工作效率和系统管理的便利性。
320 25