[linux]centos7 升级python后出现“No module named yum”错误

公司服务器重新安装系统后,手动升级python2.7.5到2.7.15,安装完python在更新系统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.15 (default, May 21 2018, 11:43: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

考虑到原来系统使用的python版本为2.7.5,手动编译安装python2.7.5版本后还是出现该问题。

解决方法:

下载下列文件:
python-2.4.3-46.el5_8.2.i386.rpm
python-devel-2.4.3-46.el5_8.2.i386.rpm
python-libs-2.4.3-46.el5_8.2.i386.rpm
python-tools-2.4.3-46.el5_8.2.i386.rpm
tix-8.4.0-11.fc6.i386.rpm
tix-devel-8.4.0-11.fc6.i386.rpm
tkinter-2.4.3-46.el5_8.2.i386.rpm
yum-3.2.22-39.el5.centos.noarch.rpm

下载地址:
http://mirrors.163.com/centos/7/os/x86_64/Packages/

[[email protected] x]# ls
python-2.4.3-46.el5_8.2.i386.rpm tix-8.4.0-11.fc6.i386.rpm
python-devel-2.4.3-46.el5_8.2.i386.rpm tix-devel-8.4.0-11.fc6.i386.rpm
python-libs-2.4.3-46.el5_8.2.i386.rpm tkinter-2.4.3-46.el5_8.2.i386.rpm
python-tools-2.4.3-46.el5_8.2.i386.rpm yum-3.2.22-39.el5.centos.noarch.rpm

[[email protected] x]# rpm -Uvh --replacepkgs *.rpm
Preparing... ########################################### [100%]
1:tix ########################################### [ 13%]
2:tix-devel ########################################### [ 25%]
3:python ########################################### [ 38%]
4:tkinter ########################################### [ 50%]
5:python-devel ########################################### [ 63%]
6:python-libs ########################################### [ 75%]
7:python-tools ########################################### [ 88%]
8:yum ########################################### [100%]
[[email protected] x]# yum update

更新系统yum文件

mv /bin/python2.7 /bin/python2.7.5

# 修改yum文件引用的python版本vim /usr/bin/yum#!/bin/python2.7.5  <--- 修改为


原文地址:https://www.cnblogs.com/aaronliu/p/9070044.html

时间: 2024-12-28 16:20:31

[linux]centos7 升级python后出现“No module named 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 yum Please install a package which provides this module, or verify that the module is installed c

CentOS6.5 安装Python2.7后, yum出现“No module named yum”错误

安装如下方法安装python2.7: yum install –y python27 python27-devel Python-docutils cd /usr/bin/ rm -rf python cp python2.7 python   出现yum错误:No module named yum 解决方法,查看 /usr/bin下python有哪几个版本 ll /usr/bin 我这里是:2.6  和  2.7 (刚安装的) 由于yum命令不兼容python2.7,需修改/usr/bin/y

linux下面升级 Python版本并修改yum属性信息

最近需要在linux下使用python,故需要升级一下python版本,上网查询了一下相关资料,更新了一下linux下面的python环境,记录如下: 首先linux下查询python版本 [[email protected] chengshaoling]# python -V Python 2.7.5 1.最新版本python下载安装 下载新版本的python python主站相关地址: https://www.python.org/downloads/source/ https://www.

python升级导致yum不可用 “ No module named yum”

最近在看python,虚拟机装的是Centos6.6,自带的python版本是2.6.6,打算升级到2.7. 我的升级过程大致如下: 下载2.7源码包https://www.python.org/downloads/source/ 卸载旧的python,rpm -e python 编译安装python2.7 整个过程没有遇到问题,但升级完后,再用yum安装软件时报如下错误 [[email protected] python]# yum There was a problem importing 

python 升级到2.7.8 导致yum 运行异常:No module named yum

os version: [[email protected] etc]# cat redhat-release Red Hat Enterprise Linux Server release 5.4 (Tikanga) ---运行yum 报错 [[email protected] ~]# yum install dialog There was a problem importing one of the Python modules required to run yum. The error

CentOS 6.5升级Python后yum不可用的解决方案

因开发需要,今天把CentOS 6.5自带的Python2.6.6升级到了Python2.7.3.按照如下步骤进行升级 1.查看当前系统python的版本 python -V 2.下载2.7.3版本的Python wget http://python.org/ftp/python/2.7.3/Python-2.7.3.tar.bz2 3.解压和安装 tar -jxvf Python-2.7.3.tar.bz2 #进入解压后的目录 cd Python-2.7.3 #编译和安装 ./configur

Python:ModuleNotFoundError: No module named &#39;windows&#39;

pymouse安装后,又出现了ModuleNotFoundError: No module named 'windows'的错误 解决: 下载安装pyhook:http://www.lfd.uci.edu/~gohlke/pythonlibs/ ctrl+f 查找 安装 pip install D:\Desktop\Download\pyHook-1.5.1-cp37-cp37m-win_amd64.whl 安装成功后,再安装 pip install PyUserinput 运行文件就没有Mod

linux 安装python3.7 报错No module named &#39;_ctypes&#39;

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遇到ModuleNotFoundError: No module named &#39;email.mime&#39;; &#39;email&#39; is not a package问题的处理办法

Python遇到ModuleNotFoundError: No module named 'email.mime'; 'email' is not a package问题的处理办法 一般有以下3个可能: 一是没有导入包 二是当前文件命名和包名冲突 三是和当前文件同一路径下其他文件命名与包名冲突 Python遇到ModuleNotFoundError: No module named 'email.mime'; 'email' is not a package问题的处理办法 原文地址:https: