下载2.7源码包https://www.python.org/downloads/source/
卸载旧的python,rpm -e python
编译安装python2.7
一起牛网_苹果安卓手游族群聚集地!
发布时间:2021-06-29 10:59:20来源:一起牛手游网作者:一起牛手游网
最近在看python,虚拟机装的是Centos6.6,自带的python版本是2.6.6,打算升级到2.7。
我的升级过程大致如下:
整个过程没有遇到问题,但升级完后,再用yum安装软件时报如下错误
[root@localhost python]# 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 yumPlease 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.13 (r266:84292, Jan 22 2014, 09:37:14) [GCC 4.4.7 20120313 (Red Hat 4.4.7-4)]If you cannot solve this problem yourself, please go to the yum faq at: http://yum.baseurl.org/wiki/Faq
yum不可用了,这下问题就大了,spacer.gif没有yum,安装rpm包特别费劲。
开始百度关键字“No module named yum”,出来很多帖子和博客,博客上边说的大概意思就是yum就基于python的,升级python后,yum与高版本的python不兼容,导致yum无法使用。博客上给出的方法都是修改/usr/bin/yum文件的头部,把/usr/bin/python修改为/usr/bin/python2.6就可以了,但我的情况是我把旧的python已经卸载了,于是又开始安装2.6版本的python。
安装好2.6.6版本的之后以为就好了,但是还是报有错误:
[root@localhost python]# 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 yumPlease 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, Jan 22 2014, 09:37:14) [GCC 4.4.7 20120313 (Red Hat 4.4.7-4)]If you cannot solve this problem yourself, please go to the yum faq at: http://yum.baseurl.org/wiki/Faq
这就奇怪了,都已经把旧版本的装上了,还是不行。这时看到一篇博客是把python和yum都全部卸载后重新安装的。想想这也是个办法于是就又全部下载
whereis python |xargs rm -rf rpm -e –nodeps python
卸载后重新安装,从光盘镜像里找到python和yum的包
rpm -ivh –nodeps python* rpm -ivh –nodeps yum*
这次总该好了吧,验证一下
[root@localhost python]# python Python 2.6.6 (r266:84292, Jan 22 2014, 09:37:14) [GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2 Type “help”, “copyright”, “credits” or “license” for more information. >>> import yum Traceback (most recent call last): File “<stdin>”, line 1, in <module> File “/usr/lib/python2.6/site-packages/yum/__init__.py”, line 23, in <module> import rpm ImportError: No module named rpm
还是报错。。。
spacer.gif不过这次错误变了,变成了“No module named rpm”
再次百度,看到有人说是缺少包:rpm -ivh rpm-python-4.8.0-37.el6.i686.rpm
安装上面的包后一切yum恢复正常了。
那问题又来了难道因为yum就不升级python版本吗?当然不是。其实是我在安装新版python的时候把旧版本的也卸载了才导致这样的问题。
后来在不卸载2.6版本的python是,重新编译安装2.7版本,安装成功并且yum仍然可用。
下载2.7源码包https://www.python.org/downloads/source/ 卸载旧的python,rpm -e python 编译安装python2.7
食物语手游腊味合蒸高阶阵容打法思路一览
神雕侠侣2手游氪金玩家消费指南
王牌战士幽灵实战技巧讲解
爱江山更爱美人游戏中宫论战攻略
王牌战士团战如何切入详细讲解
和平精英通讯塔是什么 和平精英通讯塔玩法详细解析
暴走英雄坛延生保命丹怎么用 延生保命丹平民用法攻略
凌烟诀新手前期武学学习与主线攻略
梦幻西游三维版每日日常活动任务安排流程攻略
王者荣耀
角色扮演
坠落星界
其它游戏
炽姬无双
角色扮演
梦三国
角色扮演
跑跑卡丁车官方竞速版
体育竞技
邪恶疯人院
休闲益智
征途永恒
角色扮演
传奇世界3D
角色扮演
一刀传世
角色扮演