标签归档:yum

python升级导致yum使用报错

刚开始怀疑是不是yum源出问题了,把阿里云的源重新下载加载

cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget -P /etc/yum.repos.d/ http://mirrors.aliyun.com/repo/epel-7.repo 
yum clean all  
yum makecache

发现不行,还是报错

检查下python版本

python
# python
Python 2.7.5 (default, Oct 30 2018, 23:45:53) 

发现python已经被升级到2.7.5,而yum需要的python版本是2.6,导致的报错

修改yum启动文件前缀

# cat /usr/bin/yum
#!/usr/bin/python2.7

发现没有用,没有备份,python直接被更新到2.7.5,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.

查找资料,尝试再安装个python2.6.6版本,修改yum启动文件,但是还是出现模块不能加载
重装python和yum

1、卸载现有的python,强制删除已安装程序及其关联

rpm -qa|grep python|xargs rpm -ev --allmatches --nodeps

强制删除所有残余文件

whereis python |xargs rm -frv

2、卸载现有的yum

rpm -qa|grep yum|xargs rpm -ev --allmatches --nodeps

强制删除所有残余文件

whereis yum |xargs rm -frv

3、下载版本对应的rpm包

wget http://mirrors.ustc.edu.cn/centos/7/os/x86_64/Packages/libxml2-python-2.9.1-6.el7_2.3.x86_64.rpm

wget http://mirrors.ustc.edu.cn/centos/7/os/x86_64/Packages/rpm-4.11.3-35.el7.x86_64.rpm
wget http://mirrors.ustc.edu.cn/centos/7/os/x86_64/Packages/rpm-build-4.11.3-35.el7.x86_64.rpm
wget http://mirrors.ustc.edu.cn/centos/7/os/x86_64/Packages/rpm-build-libs-4.11.3-35.el7.x86_64.rpm
wget http://mirrors.ustc.edu.cn/centos/7/os/x86_64/Packages/rpm-libs-4.11.3-35.el7.x86_64.rpm
wget http://mirrors.ustc.edu.cn/centos/7/os/x86_64/Packages/rpm-sign-4.11.3-35.el7.x86_64.rpm
wget http://mirrors.ustc.edu.cn/centos/7/os/x86_64/Packages/rpm-python-4.11.3-35.el7.x86_64.rpm

wget http://mirrors.ustc.edu.cn/centos/7/os/x86_64/Packages/python-2.7.5-76.el7.x86_64.rpm
wget http://mirrors.ustc.edu.cn/centos/7/os/x86_64/Packages/python-devel-2.7.5-76.el7.x86_64.rpm
wget http://mirrors.ustc.edu.cn/centos/7/os/x86_64/Packages/python-libs-2.7.5-76.el7.x86_64.rpm
wget http://mirrors.ustc.edu.cn/centos/7/os/x86_64/Packages/python-pycurl-7.19.0-19.el7.x86_64.rpm
wget http://mirrors.ustc.edu.cn/centos/7/os/x86_64/Packages/python-setuptools-0.9.8-7.el7.noarch.rpm
wget http://mirrors.ustc.edu.cn/centos/7/os/x86_64/Packages/python-urlgrabber-3.10-9.el7.noarch.rpm
wget http://mirrors.ustc.edu.cn/centos/7/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm
wget http://mirrors.ustc.edu.cn/centos/7/os/x86_64/Packages/python-backports-1.0-8.el7.x86_64.rpm
wget http://mirrors.ustc.edu.cn/centos/7/os/x86_64/Packages/python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch.rpm
wget http://mirrors.ustc.edu.cn/centos/7/os/x86_64/Packages/python-chardet-2.2.1-1.el7_1.noarch.rpm
wget http://mirrors.ustc.edu.cn/centos/7/os/x86_64/Packages/python-ipaddress-1.0.16-2.el7.noarch.rpm
wget http://mirrors.ustc.edu.cn/centos/7/os/x86_64/Packages/python-kitchen-1.1.1-5.el7.noarch.rpm
wget http://mirrors.ustc.edu.cn/centos/7/os/x86_64/Packages/python-virtualenv-15.1.0-2.el7.noarch.rpm

wget http://mirrors.ustc.edu.cn/centos/7/os/x86_64/Packages/yum-3.4.3-161.el7.centos.noarch.rpm
wget http://mirrors.ustc.edu.cn/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
wget http://mirrors.ustc.edu.cn/centos/7/os/x86_64/Packages/yum-utils-1.1.31-50.el7.noarch.rpm
wget http://mirrors.ustc.edu.cn/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-50.el7.noarch.rpm
wget http://mirrors.ustc.edu.cn/centos/7/os/x86_64/Packages/yum-plugin-protectbase-1.1.31-50.el7.noarch.rpm
wget http://mirrors.ustc.edu.cn/centos/7/os/x86_64/Packages/yum-plugin-aliases-1.1.31-50.el7.noarch.rpm

下载完成后安装这些包(–force强制安装)

rpm -Uvh --force --nodeps --replacepkgs *.rpm

安装完这些rpm包后,yum就可以正常使用了,如果还是报下面这个,说明你rpm包没下载全

There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:

   /usr/lib64/python2.7/site-packages/rpm/_rpm.so: undefined symbol: rpmpkgVerifySi

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, Apr 11 2018, 07:36:10)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]

If you cannot solve this problem yourself, please go to
the yum faq at:
  http://yum.baseurl.org/wiki/Faq

重要的事情说三遍
python升级用下载的包升级,升级前先备份旧版本!!!

来源:https://www.cnblogs.com/guantou1992/p/10472121.html

CentOS 6通过yum安装GCC4.7 4.8 4.9 5.3 6.3 7.3等高版本GCC

再说一下已经停止支持的devtoolset4(gcc 5.2)及之前版本的安装方法
gcc 4.7 安装

    wget http://people.centos.org/tru/devtools-1/devtools-1.repo -O /etc/yum.repos.d/devtoolset-1.repo
    yum install centos-release-scl
    yum install devtoolset-1-toolchain
    scl enable devtoolset-1 bash
    gcc --version

gcc 4.8 安装

curl -Lks http://www.hop5.in/yum/el6/hop5.repo > /etc/yum.repos.d/hop5.repo
yum install gcc gcc-g++
gcc --version

或者使用官方工具

    wget http://people.centos.org/tru/devtools-2/devtools-2.repo -O /etc/yum.repos.d/devtoolset-2.repo
    yum install centos-release-scl
    yum install devtoolset-2-toolchain
    scl enable devtoolset-2 bash
    gcc --version

gcc 4.9 安装

    yum install centos-release-scl
    yum install devtoolset-3-toolchain
    scl enable devtoolset-3 bash
    gcc --version

gcc 5.3 安装

    yum install centos-release-scl
    yum install devtoolset-4-toolchain
    scl enable devtoolset-4 bash
    gcc --version

gcc 6.3 安装

    yum install centos-release-scl
    yum install devtoolset-6-toolchain
    scl enable devtoolset-6 bash
    gcc --version

gcc 7.3 安装

    yum install centos-release-scl
    yum install devtoolset-7-toolchain
    scl enable devtoolset-7 bash
    gcc --version

scl enable devtoolset-3 bash 只是临时覆盖系统原有的GCC引用,重启后恢复原来的GCC,如果想永久覆盖,
可在/etc/bashrc文件中添加

source /opt/rh/devtoolset-3/enable

或者:如果root单独使用,在/root/.bashrc文件中添加

source /opt/rh/devtoolset-3/enable

重启后生效。

文件参考: https://www.quyu.net/info/876.html
https://www.dwhd.org/20160724_085212.html