-bash: yum: command not found
rpm -ivh --force --nodeps yum-metadata-parser-1.1.2-14.1.el6.x86_64.rpm
rpm -ivh --force --nodeps yum-3.2.29-69.el6.centos.noarch.rpm yum-plugin-fa
stestmirror-1.1.30-30.el6.noarch.rpm
最近在看python,虚拟机装的是Centos6.6,自带的python版本是2.6.6,打算升级到2.7。
我的升级过程大致如下:
整个过程没有遇到问题,但升级完后,再用yum安装软件时报如下错误
[aaa@qq.com 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 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.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版本的之后以为就好了,但是还是报有错误:
[aaa@qq.com 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 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.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*
这次总该好了吧,验证一下
[aaa@qq.com 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仍然可用。
反正上面几个哥们包括Stack Overflow找了一遍,我试了都不行,然后把其他机器的/usr/bin下面的ll python*文件拷过来,就搞定了~~推荐阅读
-
bash scp command not found的解决方法
-
ubuntu下安装vue/cli提示No command 'vue' found
-
linux 执行 javac 报错 javac: command not found
-
解决 bash: vue command not found
-
sudo service: command not found 报错的解决方法
-
linux下提示bash:command not found
-
-bash: mysqladmin: command not found问题解决
-
覆盖原先的PATH导致命令失效提示command not found的解决方法
-
mysql: command not found
-
python 错误信息是:sudo :apt-get:command not found