公司测试机环境不知道给我卸了什么包,导致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 sqlite

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:

一、升级或卸载Python导致:

1
2
3
4
5
6
7
8
1、查看已安装python的版本,可能是当前系统存在多个python导致
[root@test ~]# whereis python
python: /usr/bin/python2.6 /usr/bin/python /usr/bin/python2.6-config /usr/lib/python2.6 /usr/lib64/python2.6 /usr/include/python2.6 /usr/share/man/man1/python.1.gz
[root@test ~]# vi /usr/bin/yum
#!/usr/bin/python 修改为 #!/usr/bin/python2.6
如果是源代码安装的,默认路径是/usr/local/bin/python2.6,做个软链接即可
rm -rf /usr/bin/python
ln -s /usr/local/bin/python2.6 /usr/bin/python

二、完全重装python和yum

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
1、删除现有Python
[root@test ~]# rpm -qa|grep python|xargs rpm -ev --allmatches --nodeps ##强制删除已安装程序及其关联
[root@test ~]# whereis python |xargs rm -frv ##删除所有残余文件 ##xargs,允许你对输出执行其他某些命令
[root@test ~]# whereis python ##验证删除,返回无结果
2、删除现有的yum
[root@test ~]# rpm -qa|grep yum|xargs rpm -ev --allmatches --nodeps
[root@test ~]# whereis yum |xargs rm -frv
3、从http://mirrors.ustc.edu.cn/centos/6.4/os/x86_64/Packages/下载相应的包
python-2.6.6-36.el6.x86_64.rpm
python-devel-2.6.6-36.el6.x86_64.rpm
python-libs-2.6.6-36.el6.x86_64.rpm
python-pycurl-7.19.0-8.el6.x86_64.rpm
python-setuptools-0.6.10-3.el6.noarch.rpm
python-urlgrabber-3.9.1-8.el6.noarch.rpm  
python-iniparse-0.3.1-2.1.el6.noarch.rpm
rpm-python-4.8.0-32.el6.x86_64.rpm
yum-3.2.29-40.el6.centos.noarch.rpm
yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
yum-utils-1.1.30-14.el6.noarch.rpm
yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm     
yum-plugin-protectbase-1.1.30-14.el6.noarch.rpm
yum-plugin-aliases-1.1.30-14.el6.noarch.rpm
yum-plugin-downloadonly-1.1.30-14.el6.noarch.rpm
由于源中版本会更新,具体请查看URL中的版本再下载下来!
[root@test ~]# rpm -Uvh --replacepkgs python*.rpm
[root@test ~]# rpm -Uvh --replacepkgs rpm-python*.rpm yum*.rpm
可能之间还需要zlib和zlib-devel包,根据情况下载并安装!

三、运行python进行测试

1
2
3
4
5
6
7
[root@test ~]# python
Python 2.6.6 (r266:84292, Feb 22 2013, 00:00:18)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import yum
>>>
如上,要是什么都没报,则说明OK啦~

本文出自 “SmilePad” 博客,请务必保留此出处http://smilepad.blog.51cto.com/6094369/1333478

CentOS6.5运行yum报错:No module named yum的更多相关文章

  1. centos6.5 导入matplotlib报错 No module named '_tkinter

    1.解决方案 在centos系统下,导入matplotlib时,出现ImportError: No module named ‘_tkinter’的错误,首先 yum list installed | ...

  2. yum源使用的几个报错小总结 (例如: python2.6.6 下yum不能使用: No module named yum)

    服务器上的yum突然不好使用,使用yum时有如下几个保持,解决方案如下: 1)Error: Cannot retrieve repository metadata (repomd.xml) for r ...

  3. python踩坑系列之导入包时下划红线及报错“No module named”问题

    python踩坑系列之导入包时下划红线及报错“No module named”问题 使用pycharm编写Python时,自己写了一个包(commontool),在同级另一个路径下(fileshand ...

  4. mac 上python编译报错No module named MySQLdb

    mac 上python编译报错No module named MySQLdb You installed python You did brew install mysql You did expor ...

  5. 解决运行scrapy是报错No module named cryptography,解决cryptography的安装问题,解决libffi的安装问题

    在linux下配置完运行是出现ImportError: No module named cryptography.hazmat.bindings.openssl.binding的错误.原因是crapt ...

  6. Django:django-cors-headers 报错no module named "corsheaders"

    django跨域使用 pip install django-cors-headers 然后在settings文件中加上参数设置 # app配置 INSTALLED_APPS = [ 'django.c ...

  7. yum报错File "/usr/bin/yum", line 30 except KeyboardInterrupt, e:

    原因:学python的时候,把centos7自带的python2.7改成了python3.6.2.而yum使用的是python2,所以会出现yum报错. 解决方法: 在文件/usr/bin/yum./ ...

  8. python manage.py startapp app 时候报错No module named _sqlite3

    python manage.py startapp app 报错如下: File "manage.py", line 10, in <module>    execut ...

  9. salt-minion启动报错No module named salt.scripts

    这是当初部署saltstack时候的问题了,saltstack用的是0.17.4的版本.正当minion部署到最后时候,启动 minion端时报错ImportError: No module name ...

  10. C#调用Python,报错No module named os

    C#调用Python 环境:Windows 8.1,已经安装Python2.7(C:\Python27),配置了环境变量. 已经安装VS2013,VS2017 1.安装IronPython 下载地址h ...

随机推荐

  1. 【BZOJ1800】[AHOI2009]飞行棋(暴力)

    [BZOJ1800][AHOI2009]飞行棋(暴力) 题面 BZOJ 洛谷 题解 预处理一下前缀和就可以\(O(1)\)计算两点间的距离了,直接\(O(n^4)\)暴力枚举即可. #include& ...

  2. [HEOI2013]SAO ——计数问题

    题目大意: Welcome to SAO ( Strange and Abnormal Online).这是一个 VR MMORPG, 含有 n 个关卡.但是,挑战不同关卡的顺序是一个很大的问题. 有 ...

  3. Spring实现文件的上传下载

    背景:之前一直做的是数据库的增删改查工作,对于文件的上传下载比较排斥,今天研究了下具体的实现,发现其实是很简单.此处不仅要实现单文件的上传,还要实现多文件的上传. 单文件的下载知道了,多文件的下载呢? ...

  4. Django model中的 class Meta 详解

    通过一个内嵌类 "class Meta" 给你的 model 定义元数据, 类似下面这样: class Foo(models.Model): bar = models.CharFi ...

  5. 装饰页面decorators.xml

    WEB-INF/decorators.xml 这个配置可以增加页面的 装饰页面

  6. linux command ------ find

    find | grep luoluo 将当前目录及子目录的文件名中含有luoluo的文件过滤出来 | 是管道,把find查找的内容传递给下个命令(grep) find后面不加其他内容(比如路径)表示打 ...

  7. es7预览

    哈哈,es6才刚刚掌握,就给大家介绍es7了. es7的草案其实早已经定下来了,而且更加向着java这些高级语言看齐了 chrome的高版本其实也已经对es7的部分功能实现了!! 1.数组 inclu ...

  8. selenium批量翻译

    Python爬虫视频教程零基础小白到scrapy爬虫高手-轻松入门 https://item.taobao.com/item.htm?spm=a1z38n.10677092.0.0.482434a6E ...

  9. MySQL 5.6版本内存占用过高的解决办法

    最近在阿里云购买了一台云服务器,因为是自己测试玩的,所以配置按最低的来了,1G内存,然后啪啪啪(指键盘声音)的安装了JDK,Tomcat,MySQL(5.6)等一系列环境,开始很爽,然后噩梦开始了: ...

  10. Jedis操作笔记 redis的五种存储类型

    常用数据类型简介: redis常用五种数据类型:string,hash,list,set,zset(sorted set). 1.String类型 String是最简单的类型,一个key对应一个val ...