小威wei yum update
了一把,结果yum就报错了,Python版本并没有升级,依然是2.7.5版本。
[root@localhost ~]# 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 gzip
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, Aug 4 2017, 00:39:18)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)]
If you cannot solve this problem yourself, please go to
the yum faq at:
http://yum.baseurl.org/wiki/Faq
No module named gzip报错提示没有gzip,一开始以为是系统的gzip木有了,跑去清华大学的mirrors上面把gzip包download安装了一下发现yum还是顽强的报错No module named gzip。仔细阅读报错信息后确认这个报错跟Python有关系,于是就进入Python import了一下gzip,果然报错了。
[root@localhost ~]# python
Python 2.7.5 (default, Aug 4 2017, 00:39:18)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import gzip
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named gzip
找到病根就好治病了,跑到另外一台服务器上面去,查看了一下gzip模块的位置(python的模块其实就是几个文件),拷贝到这台服务器上面就可以了。
登陆到我博客的服务器(腾讯云服务器)看一下gzip模块的位置并下载下来。
[root@qcloud ~]# python
Python 2.7.5 (default, Aug 4 2017, 00:39:18)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import gzip
>>> print gzip.__file__
/usr/lib64/python2.7/gzip.pyc
[root@qcloud ~]# cd /usr/lib64/python2.7/
[root@qcloud python2.7]# ls gzip.py
gzip.py gzip.pyc gzip.pyo # gzip模块就是这三个文件
拷贝这三个文件(gzip.py gzip.pyc gzip.pyo)到服务器相同位置下面。
[root@localhost ~]# cd /usr/lib64/python2.7
[root@localhost python2.7]# rz
[root@localhost python2.7]# rz
[root@localhost python2.7]# rz
再来import一下gzip模块,测试一下模块是否恢复成功。
[root@localhost python2.7]# python
Python 2.7.5 (default, Aug 4 2017, 00:39:18)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import gzip # 没有报错
gzip模块import成功了,再来看下yum是否可用。
[root@localhost python2.7]# yum
Loaded plugins: fastestmirror
You need to give some command
Usage: yum [options] COMMAND
List of Commands:
check Check for problems in the rpmdb
.....
执行了一下yum,发现已经正常了(最好是yum clean all一下)。来install一个软件测试一下还有没有暗病。
[root@localhost python2.7]# yum -y install htop
Loaded plugins: fastestmirror
base | 3.6 kB 00:00:00
epel/x86_64/metalink | 7.3 kB 00:00:00
epel | 4.7 kB 00:00:00
extras | 3.4 kB 00:00:00
updates | 3.4 kB 00:00:00
(1/7): base/7/x86_64/group_gz | 156 kB 00:00:00
(2/7): epel/x86_64/group_gz | 266 kB 00:00:00
(3/7): extras/7/x86_64/primary_db | 185 kB 00:00:00
(4/7): updates/7/x86_64/primary_db | 6.9 MB 00:00:06
(5/7): epel/x86_64/updateinfo
.....
好了,软件可以安装,问题成功解决了,但是至于为什么yum update一下就把gzip模块搞废了,还得详细的查看一下”案发现场”才知道了。