CentOS6.5运行yum报错:No module named yum

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

[[email protected]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

[[email protected]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

[[email protected]test ~]# rpm -qa|grep python|xargs rpm -ev --allmatches --nodeps ##强制删除已安装程序及其关联

[[email protected]test ~]# whereis python |xargs rm -frv ##删除所有残余文件 ##xargs,允许你对输出执行其他某些命令

[[email protected]test ~]# whereis python ##验证删除,返回无结果

2、删除现有的yum

[[email protected]test ~]# rpm -qa|grep yum|xargs rpm -ev --allmatches --nodeps

[[email protected]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中的版本再下载下来!

[[email protected]test ~]# rpm -Uvh --replacepkgs python*.rpm

[[email protected]test ~]# rpm -Uvh --replacepkgs rpm-python*.rpm yum*.rpm

可能之间还需要zlib和zlib-devel包,根据情况下载并安装!

三、运行python进行测试


1

2

3

4

5

6

7

[[email protected]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

时间: 2024-10-14 19:11:21

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

yum执行报错No module named yummain处理

今天上服务器上执行yum install   htop出现 import yummain导入报错No module named yummain,于是百度查找问题处理方案,但是网上数说 执行yum clean all 即可  但是这个yum都不能执行了  clean 肯定也不行 1:解决方式 1获取yummain的安装的py文件 [[email protected] ~]# wget  http://yum.baseurl.org/download/3.4/yum-3.4.0.tar.gz [[e

flask报错No module named 'flask.ext'

解决: from flask.ext.httpauth import HTTPBasicAuth 改为 from flask_httpauth import HTTPBasicAuth 提示ModuleNotFoundError: No module named 'flask_httpauth' pip install flask_httpauth 然后即可运行. flask报错No module named 'flask.ext' 原文地址:https://www.cnblogs.com/se

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

django跨域使用 pip install django-cors-headers 然后在settings文件中加上参数设置 # app配置 INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles

linux 安装python3.7 报错No module named '_ctypes'

ModuleNotFoundError: No module named '_ctypes' 操作系统:centos yum install libffi-devel ./configure --enable-optimizations make altinstall 参考:https://bugs.python.org/issue31652 linux 安装python3.7 报错No module named '_ctypes' 原文地址:https://www.cnblogs.com/bo

解压版本Python,手动安装pip报错,pip得到报错" No module named 'pip' "

解压版本Python,手动安装pip报错 λ pip Traceback (most recent call last): File "runpy.py", line 193, in _run_module_as_main File "runpy.py", line 86, in _run_code File "D:\tools\python-3.8.1-embed-amd64\Scripts\pip.exe\__main__.py", line

机器学习在用到mnist数据集报错No module named 'tensorflow.examples.tutorials'解决办法

检查一下安装有tensorflow包的目录下的examples这个文件夹. 每个人的文件路径是不同的,我的在...\Python3\Lib\site-packages,该目录下有文件夹tensorflow, tensorflow_core, tensorflow_estimator等文件夹.进入tensorflow文件夹,里面发现一个examples文件夹,但是文件夹下只有saved_model这个文件,没有找到tutorials. 接下来我们进入github的tensorflow主页下载缺失的

Ubuntu安装Sqlite报错:No module named 'ConfigParser'

安装命令:`sudo apt install sqlite` 原因,我把系统默认的python版本改为了python3 改为python2即可,用update-alternatives命令,见此文(方法2):http://blog.csdn.net/u011534057/article/details/51615193 Ubuntu安装Sqlite报错:No module named 'ConfigParser' 原文地址:https://www.cnblogs.com/qrlozte/p/85

Django报错 No module named 'django.templates'

前言 Django 模板报错了 修改方法: 将你的工程文件下(my_site)的settings.py中的TEMPLATES中的templates字段全部改为template, 亲测可用~^~ Django报错 No module named 'django.templates' 原文地址:https://www.cnblogs.com/yf-html/p/9314280.html

python3报错No module named _ssl

问题:在python使用过程中,发现报错No module named _ssl,但是系统已经安装opensll,于是开始了解决问题之旅原因:python3支持openssl版本最低为1.0.2,而系统比较老,自带的openssl版本为1.0.2参考 https://www.jianshu.com/p/3ec24f563b81 安装新版openssl 下载 https://www.openssl.org/source/ 安装 mkdir /usr/local/openssl tar xf ope

python_执行报错_No module named 'pandas'

程序中代码如下: 报错: 根据链接( http://www.pianshen.com/article/6871295514/  )中指导,解决过程如下: File  --> Settings  -->  Project ( Project Interpreter ) --> 点击其中加号 --> 搜索 pandas ,然后点击安装. python_执行报错_No module named 'pandas' 原文地址:https://www.cnblogs.com/lyj0123/p